lucky-cli 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. lucky_cli-0.0.3/.github/workflows/release.yml +34 -0
  2. lucky_cli-0.0.3/.gitignore +220 -0
  3. lucky_cli-0.0.3/.python-version +1 -0
  4. lucky_cli-0.0.3/AGENTS.md +150 -0
  5. lucky_cli-0.0.3/CLAUDE.md +150 -0
  6. lucky_cli-0.0.3/LICENSE +21 -0
  7. lucky_cli-0.0.3/PKG-INFO +141 -0
  8. lucky_cli-0.0.3/README.md +106 -0
  9. lucky_cli-0.0.3/docs/superpowers/plans/2026-06-21-lucky-cli-v1.md +2321 -0
  10. lucky_cli-0.0.3/docs/superpowers/specs/2026-06-21-lucky-cli-design.md +130 -0
  11. lucky_cli-0.0.3/pyproject.toml +38 -0
  12. lucky_cli-0.0.3/setup.cfg +4 -0
  13. lucky_cli-0.0.3/src/lucky/__init__.py +0 -0
  14. lucky_cli-0.0.3/src/lucky/cli.py +48 -0
  15. lucky_cli-0.0.3/src/lucky/commands/__init__.py +0 -0
  16. lucky_cli-0.0.3/src/lucky/commands/check.py +50 -0
  17. lucky_cli-0.0.3/src/lucky/commands/pick.py +28 -0
  18. lucky_cli-0.0.3/src/lucky/commands/show.py +55 -0
  19. lucky_cli-0.0.3/src/lucky/config.py +9 -0
  20. lucky_cli-0.0.3/src/lucky/console/__init__.py +0 -0
  21. lucky_cli-0.0.3/src/lucky/console/rich.py +129 -0
  22. lucky_cli-0.0.3/src/lucky/database/__init__.py +0 -0
  23. lucky_cli-0.0.3/src/lucky/database/db.py +19 -0
  24. lucky_cli-0.0.3/src/lucky/database/models.py +34 -0
  25. lucky_cli-0.0.3/src/lucky/database/repository.py +57 -0
  26. lucky_cli-0.0.3/src/lucky/lottery/__init__.py +1 -0
  27. lucky_cli-0.0.3/src/lucky/lottery/base.py +57 -0
  28. lucky_cli-0.0.3/src/lucky/lottery/checker.py +23 -0
  29. lucky_cli-0.0.3/src/lucky/lottery/generator.py +16 -0
  30. lucky_cli-0.0.3/src/lucky/lottery/mega.py +12 -0
  31. lucky_cli-0.0.3/src/lucky/lottery/powerball.py +12 -0
  32. lucky_cli-0.0.3/src/lucky/lottery/stats.py +48 -0
  33. lucky_cli-0.0.3/src/lucky/updater/__init__.py +0 -0
  34. lucky_cli-0.0.3/src/lucky/updater/client.py +7 -0
  35. lucky_cli-0.0.3/src/lucky/updater/fixtures/mega-millions.json +4 -0
  36. lucky_cli-0.0.3/src/lucky/updater/fixtures/powerball.json +5 -0
  37. lucky_cli-0.0.3/src/lucky/updater/sources.py +35 -0
  38. lucky_cli-0.0.3/src/lucky/updater/updater.py +32 -0
  39. lucky_cli-0.0.3/src/lucky_cli.egg-info/PKG-INFO +141 -0
  40. lucky_cli-0.0.3/src/lucky_cli.egg-info/SOURCES.txt +62 -0
  41. lucky_cli-0.0.3/src/lucky_cli.egg-info/dependency_links.txt +1 -0
  42. lucky_cli-0.0.3/src/lucky_cli.egg-info/entry_points.txt +2 -0
  43. lucky_cli-0.0.3/src/lucky_cli.egg-info/requires.txt +4 -0
  44. lucky_cli-0.0.3/src/lucky_cli.egg-info/scm_file_list.json +58 -0
  45. lucky_cli-0.0.3/src/lucky_cli.egg-info/scm_version.json +8 -0
  46. lucky_cli-0.0.3/src/lucky_cli.egg-info/top_level.txt +1 -0
  47. lucky_cli-0.0.3/tests/conftest.py +14 -0
  48. lucky_cli-0.0.3/tests/test_base.py +87 -0
  49. lucky_cli-0.0.3/tests/test_checker.py +51 -0
  50. lucky_cli-0.0.3/tests/test_cli.py +45 -0
  51. lucky_cli-0.0.3/tests/test_client.py +8 -0
  52. lucky_cli-0.0.3/tests/test_command_check.py +39 -0
  53. lucky_cli-0.0.3/tests/test_command_pick.py +22 -0
  54. lucky_cli-0.0.3/tests/test_command_show.py +50 -0
  55. lucky_cli-0.0.3/tests/test_console.py +102 -0
  56. lucky_cli-0.0.3/tests/test_db.py +34 -0
  57. lucky_cli-0.0.3/tests/test_games.py +20 -0
  58. lucky_cli-0.0.3/tests/test_generator.py +29 -0
  59. lucky_cli-0.0.3/tests/test_models.py +45 -0
  60. lucky_cli-0.0.3/tests/test_repository.py +118 -0
  61. lucky_cli-0.0.3/tests/test_sources.py +26 -0
  62. lucky_cli-0.0.3/tests/test_stats.py +74 -0
  63. lucky_cli-0.0.3/tests/test_updater.py +46 -0
  64. lucky_cli-0.0.3/uv.lock +782 -0
@@ -0,0 +1,34 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.11"
19
+
20
+ - run: pip install build twine pytest setuptools-scm
21
+
22
+ - run: pip install -e .
23
+
24
+ - run: pytest
25
+
26
+ - run: python -m build
27
+
28
+ - run: twine check dist/*
29
+
30
+ - name: Publish to PyPI
31
+ env:
32
+ TWINE_USERNAME: __token__
33
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
34
+ run: twine upload dist/*
@@ -0,0 +1,220 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
219
+ .worktrees/
220
+ /sdd/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,150 @@
1
+ # CLAUDE.md
2
+
3
+ Guidance for Claude Code when working in this repository.
4
+
5
+ ## Project
6
+
7
+ `lucky-cli` is a production-grade Python CLI package (lottery ticket generator/checker/stats), installed as the `lucky` command. This is a real PyPI-ready project, not a toy script — code should be held to the same bar as tools like `git`, `docker`, or `poetry`: clean architecture, no half-finished features, no dead code.
8
+
9
+ The repo is currently a bare skeleton (`pyproject.toml`, `main.py`, `LICENSE`, `README.md`) — most of the structure below does not exist yet and needs to be built.
10
+
11
+ ## Tech stack (strict — do not substitute)
12
+
13
+ - Python 3.11+
14
+ - Typer for the CLI (not Click directly, even though Typer wraps it)
15
+ - Rich for all terminal UI (tables, panels, progress bars, spinners) — avoid raw `print()` except for debugging
16
+ - SQLite for local persistence
17
+ - SQLAlchemy as the ORM layer
18
+ - httpx as the HTTP client
19
+ - pytest for tests
20
+ - setuptools + setuptools-scm for versioning (version comes from git tags, never hardcoded)
21
+ - GitHub Actions for CI/CD
22
+ - dev workflow uses `uv` locally (`uv run`, `uv sync`, etc.)
23
+
24
+ ## Project structure
25
+
26
+ ```
27
+ lucky-cli/
28
+ ├── pyproject.toml
29
+ ├── README.md
30
+ ├── LICENSE
31
+ ├── CHANGELOG.md
32
+ ├── src/
33
+ │ └── lucky/
34
+ │ ├── __init__.py
35
+ │ ├── cli.py
36
+ │ ├── config.py
37
+ │ ├── commands/
38
+ │ │ ├── pick.py
39
+ │ │ ├── check.py
40
+ │ │ └── show.py
41
+ │ ├── lottery/
42
+ │ │ ├── base.py # Game protocol/ABC + registry
43
+ │ │ ├── powerball.py
44
+ │ │ ├── mega.py
45
+ │ │ └── generator.py
46
+ │ ├── database/
47
+ │ │ ├── db.py
48
+ │ │ ├── models.py
49
+ │ │ └── repository.py
50
+ │ ├── updater/
51
+ │ │ ├── updater.py
52
+ │ │ ├── sources.py
53
+ │ │ └── client.py
54
+ │ └── console/
55
+ │ └── rich.py
56
+ └── tests/
57
+ ```
58
+
59
+ ## CLI surface
60
+
61
+ Entry point: `lucky` (installed via `pip install lucky-cli`).
62
+
63
+ | Command | Purpose |
64
+ |---|---|
65
+ | `lucky pick <game> [--count N]` | Generate N valid random tickets |
66
+ | `lucky check <game> <n1..n5> --special <s>` | Compare a ticket against the latest draw, show match count |
67
+ | `lucky show <game>` | Show the latest draw (date, numbers, special, jackpot) in a Rich panel — default view |
68
+ | `lucky show <game> --history [--limit N]` | Last N draws in a Rich table |
69
+ | `lucky show <game> --stats` | Number/special frequency, hot/cold numbers, odd/even distribution |
70
+ | `lucky --version` | Version read dynamically via `importlib.metadata.version`, never hardcoded |
71
+
72
+ Only three top-level commands: `pick`, `check`, `show`. `show` defaults to the latest draw; `--history` and `--stats` switch its view (mutually exclusive — don't combine them).
73
+
74
+ Supported games:
75
+ - Powerball: 5 numbers (1–69) + 1 special (1–26)
76
+ - Mega Millions: 5 numbers (1–70) + 1 special (1–25)
77
+
78
+ ### Game extensibility (design requirement)
79
+
80
+ Only Powerball and Mega Millions exist today, but the game layer must stay open for new games without touching `commands/`, `database/`, or `updater/` code:
81
+
82
+ - `lottery/base.py` defines a `Game` abstraction (ABC or `Protocol`) with the rules every game must expose: name/slug, number range, count of main numbers, special-number range (or none), and a validator for a ticket.
83
+ - Each game (`powerball.py`, `mega.py`, future ones) is a small data-driven implementation of `Game` — no game-specific branching (`if game == "powerball"`) anywhere outside `lottery/`.
84
+ - `lottery/__init__.py` (or `base.py`) exposes a registry (dict or simple lookup function) mapping a game slug string to its `Game` instance, so `commands/pick.py`, `check.py`, `show.py` resolve the game generically by slug and call shared logic (`generator.py`, stats, checker) against the `Game` interface.
85
+ - Adding a game should be: one new file in `lottery/`, one registry entry, zero changes to CLI command code or the `draws` table schema (it's already game-agnostic via `game` and the JSON number arrays — see Data layer).
86
+
87
+ ## Automatic update flow (every invocation)
88
+
89
+ Every `lucky` invocation must, before running the user's command:
90
+ 1. Check local SQLite DB timestamp
91
+ 2. Hit the remote lottery data source (mock API is acceptable)
92
+ 3. If new draws exist: download, update SQLite, show a Rich progress bar
93
+ 4. If already up to date: stay silent — no spinner, no output
94
+ 5. If offline/network failure: fall back silently to the cached DB, never crash
95
+
96
+ This auto-update behavior is a core requirement, not optional — don't let a feature command (`pick`, `check`, `show`) skip it.
97
+
98
+ ## Data layer
99
+
100
+ SQLite DB path:
101
+ - Linux/macOS: `~/.lucky-cli/lucky.db`
102
+ - Windows: `%USERPROFILE%\.lucky-cli\lucky.db`
103
+
104
+ `draws` table — one row per draw, numbers stored as JSON arrays so any game's main/special count fits without a migration:
105
+
106
+ ```sql
107
+ draws (
108
+ id INTEGER PRIMARY KEY,
109
+ game TEXT NOT NULL, -- slug, matches the lottery registry (e.g. "powerball")
110
+ date TEXT NOT NULL,
111
+ main TEXT NOT NULL, -- JSON array, e.g. "[12,18,33,44,61]"
112
+ special TEXT NOT NULL, -- JSON array, e.g. "[9]" — "[]" if a game has none
113
+ jackpot TEXT,
114
+ UNIQUE(game, date)
115
+ )
116
+ ```
117
+
118
+ The SQLAlchemy model exposes `main`/`special` as typed list properties (`json.loads`/`json.dumps` under the hood), not raw strings. `stats` unpacks the arrays in Python for frequency counts rather than relying on SQL `GROUP BY`.
119
+
120
+ ## Versioning — agent-driven, fully automated
121
+
122
+ Version numbers are never hand-edited in code. Before cutting a release:
123
+ 1. Read commit history since the last tag
124
+ 2. Classify: `feat:` → MINOR, `fix:` → PATCH, `feat!:`/`BREAKING CHANGE:` → MAJOR
125
+ 3. Compute the next semver deterministically from that classification
126
+ 4. Update `CHANGELOG.md` with a `## vX.Y.Z` section, grouped by `### Features` / `### Fixes`
127
+ 5. Create the tag with `git tag vX.Y.Z`
128
+
129
+ Commit message convention (Conventional Commits, strictly enforced): `feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`, with `feat!:` or a `BREAKING CHANGE:` footer for breaking changes.
130
+
131
+ ## CI/CD
132
+
133
+ `.github/workflows/release.yml` triggers on `push: tags: ["v*"]` and must: run pytest, `python -m build`, `twine check dist/*`, then `twine upload dist/*` using a `PYPI_API_TOKEN` secret. Don't add steps that bypass tests before publish.
134
+
135
+ ## Testing
136
+
137
+ pytest must cover: ticket generator correctness, stats calculations, checker logic, and database operations. Run with `uv run pytest`.
138
+
139
+ ## Local dev
140
+
141
+ - `uv sync` to install deps
142
+ - `uv run lucky --help` / `uv run pytest` to exercise the CLI/tests without a full install
143
+ - `uv run lucky <command>` for manual testing of new commands
144
+
145
+ ## Conventions to hold the line on
146
+
147
+ - No raw `print()` in command code — route all output through `src/lucky/console/rich.py` helpers
148
+ - No bypassing the update-check flow in any command
149
+ - No hardcoded version strings — always `importlib.metadata.version("lucky-cli")`
150
+ - Network errors must degrade to cached-DB behavior, never raise to the user
@@ -0,0 +1,150 @@
1
+ # CLAUDE.md
2
+
3
+ Guidance for Claude Code when working in this repository.
4
+
5
+ ## Project
6
+
7
+ `lucky-cli` is a production-grade Python CLI package (lottery ticket generator/checker/stats), installed as the `lucky` command. This is a real PyPI-ready project, not a toy script — code should be held to the same bar as tools like `git`, `docker`, or `poetry`: clean architecture, no half-finished features, no dead code.
8
+
9
+ The repo is currently a bare skeleton (`pyproject.toml`, `main.py`, `LICENSE`, `README.md`) — most of the structure below does not exist yet and needs to be built.
10
+
11
+ ## Tech stack (strict — do not substitute)
12
+
13
+ - Python 3.11+
14
+ - Typer for the CLI (not Click directly, even though Typer wraps it)
15
+ - Rich for all terminal UI (tables, panels, progress bars, spinners) — avoid raw `print()` except for debugging
16
+ - SQLite for local persistence
17
+ - SQLAlchemy as the ORM layer
18
+ - httpx as the HTTP client
19
+ - pytest for tests
20
+ - setuptools + setuptools-scm for versioning (version comes from git tags, never hardcoded)
21
+ - GitHub Actions for CI/CD
22
+ - dev workflow uses `uv` locally (`uv run`, `uv sync`, etc.)
23
+
24
+ ## Project structure
25
+
26
+ ```
27
+ lucky-cli/
28
+ ├── pyproject.toml
29
+ ├── README.md
30
+ ├── LICENSE
31
+ ├── CHANGELOG.md
32
+ ├── src/
33
+ │ └── lucky/
34
+ │ ├── __init__.py
35
+ │ ├── cli.py
36
+ │ ├── config.py
37
+ │ ├── commands/
38
+ │ │ ├── pick.py
39
+ │ │ ├── check.py
40
+ │ │ └── show.py
41
+ │ ├── lottery/
42
+ │ │ ├── base.py # Game protocol/ABC + registry
43
+ │ │ ├── powerball.py
44
+ │ │ ├── mega.py
45
+ │ │ └── generator.py
46
+ │ ├── database/
47
+ │ │ ├── db.py
48
+ │ │ ├── models.py
49
+ │ │ └── repository.py
50
+ │ ├── updater/
51
+ │ │ ├── updater.py
52
+ │ │ ├── sources.py
53
+ │ │ └── client.py
54
+ │ └── console/
55
+ │ └── rich.py
56
+ └── tests/
57
+ ```
58
+
59
+ ## CLI surface
60
+
61
+ Entry point: `lucky` (installed via `pip install lucky-cli`).
62
+
63
+ | Command | Purpose |
64
+ |---|---|
65
+ | `lucky pick <game> [--count N]` | Generate N valid random tickets |
66
+ | `lucky check <game> <n1..n5> --special <s>` | Compare a ticket against the latest draw, show match count |
67
+ | `lucky show <game>` | Show the latest draw (date, numbers, special, jackpot) in a Rich panel — default view |
68
+ | `lucky show <game> --history [--limit N]` | Last N draws in a Rich table |
69
+ | `lucky show <game> --stats` | Number/special frequency, hot/cold numbers, odd/even distribution |
70
+ | `lucky --version` | Version read dynamically via `importlib.metadata.version`, never hardcoded |
71
+
72
+ Only three top-level commands: `pick`, `check`, `show`. `show` defaults to the latest draw; `--history` and `--stats` switch its view (mutually exclusive — don't combine them).
73
+
74
+ Supported games:
75
+ - Powerball: 5 numbers (1–69) + 1 special (1–26)
76
+ - Mega Millions: 5 numbers (1–70) + 1 special (1–25)
77
+
78
+ ### Game extensibility (design requirement)
79
+
80
+ Only Powerball and Mega Millions exist today, but the game layer must stay open for new games without touching `commands/`, `database/`, or `updater/` code:
81
+
82
+ - `lottery/base.py` defines a `Game` abstraction (ABC or `Protocol`) with the rules every game must expose: name/slug, number range, count of main numbers, special-number range (or none), and a validator for a ticket.
83
+ - Each game (`powerball.py`, `mega.py`, future ones) is a small data-driven implementation of `Game` — no game-specific branching (`if game == "powerball"`) anywhere outside `lottery/`.
84
+ - `lottery/__init__.py` (or `base.py`) exposes a registry (dict or simple lookup function) mapping a game slug string to its `Game` instance, so `commands/pick.py`, `check.py`, `show.py` resolve the game generically by slug and call shared logic (`generator.py`, stats, checker) against the `Game` interface.
85
+ - Adding a game should be: one new file in `lottery/`, one registry entry, zero changes to CLI command code or the `draws` table schema (it's already game-agnostic via `game` and the JSON number arrays — see Data layer).
86
+
87
+ ## Automatic update flow (every invocation)
88
+
89
+ Every `lucky` invocation must, before running the user's command:
90
+ 1. Check local SQLite DB timestamp
91
+ 2. Hit the remote lottery data source (mock API is acceptable)
92
+ 3. If new draws exist: download, update SQLite, show a Rich progress bar
93
+ 4. If already up to date: stay silent — no spinner, no output
94
+ 5. If offline/network failure: fall back silently to the cached DB, never crash
95
+
96
+ This auto-update behavior is a core requirement, not optional — don't let a feature command (`pick`, `check`, `show`) skip it.
97
+
98
+ ## Data layer
99
+
100
+ SQLite DB path:
101
+ - Linux/macOS: `~/.lucky-cli/lucky.db`
102
+ - Windows: `%USERPROFILE%\.lucky-cli\lucky.db`
103
+
104
+ `draws` table — one row per draw, numbers stored as JSON arrays so any game's main/special count fits without a migration:
105
+
106
+ ```sql
107
+ draws (
108
+ id INTEGER PRIMARY KEY,
109
+ game TEXT NOT NULL, -- slug, matches the lottery registry (e.g. "powerball")
110
+ date TEXT NOT NULL,
111
+ main TEXT NOT NULL, -- JSON array, e.g. "[12,18,33,44,61]"
112
+ special TEXT NOT NULL, -- JSON array, e.g. "[9]" — "[]" if a game has none
113
+ jackpot TEXT,
114
+ UNIQUE(game, date)
115
+ )
116
+ ```
117
+
118
+ The SQLAlchemy model exposes `main`/`special` as typed list properties (`json.loads`/`json.dumps` under the hood), not raw strings. `stats` unpacks the arrays in Python for frequency counts rather than relying on SQL `GROUP BY`.
119
+
120
+ ## Versioning — agent-driven, fully automated
121
+
122
+ Version numbers are never hand-edited in code. Before cutting a release:
123
+ 1. Read commit history since the last tag
124
+ 2. Classify: `feat:` → MINOR, `fix:` → PATCH, `feat!:`/`BREAKING CHANGE:` → MAJOR
125
+ 3. Compute the next semver deterministically from that classification
126
+ 4. Update `CHANGELOG.md` with a `## vX.Y.Z` section, grouped by `### Features` / `### Fixes`
127
+ 5. Create the tag with `git tag vX.Y.Z`
128
+
129
+ Commit message convention (Conventional Commits, strictly enforced): `feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`, with `feat!:` or a `BREAKING CHANGE:` footer for breaking changes.
130
+
131
+ ## CI/CD
132
+
133
+ `.github/workflows/release.yml` triggers on `push: tags: ["v*"]` and must: run pytest, `python -m build`, `twine check dist/*`, then `twine upload dist/*` using a `PYPI_API_TOKEN` secret. Don't add steps that bypass tests before publish.
134
+
135
+ ## Testing
136
+
137
+ pytest must cover: ticket generator correctness, stats calculations, checker logic, and database operations. Run with `uv run pytest`.
138
+
139
+ ## Local dev
140
+
141
+ - `uv sync` to install deps
142
+ - `uv run lucky --help` / `uv run pytest` to exercise the CLI/tests without a full install
143
+ - `uv run lucky <command>` for manual testing of new commands
144
+
145
+ ## Conventions to hold the line on
146
+
147
+ - No raw `print()` in command code — route all output through `src/lucky/console/rich.py` helpers
148
+ - No bypassing the update-check flow in any command
149
+ - No hardcoded version strings — always `importlib.metadata.version("lucky-cli")`
150
+ - Network errors must degrade to cached-DB behavior, never raise to the user
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PyDeployer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.