Metadata-Version: 2.4
Name: reku
Version: 0.1.5
Summary: Refaktoryzacja hardkodowanych wartości, struktur i kodu w projektach Python
Author-email: Tom Sapletta <tom@sapletta.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/semcod/reko
Project-URL: Repository, https://github.com/semcod/reko
Project-URL: Issues, https://github.com/semcod/reko/issues
Keywords: refactoring,hardcoded,magic-numbers,constants,static-analysis,code-quality,python
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.12.0
Requires-Dist: rich>=13.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: tomli>=2.0; python_version < "3.11"
Provides-Extra: apply
Requires-Dist: libcst>=1.0; extra == "apply"
Provides-Extra: dev
Requires-Dist: reku[apply]; extra == "dev"
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: costs>=0.1.20; extra == "dev"
Dynamic: license-file

# reko


## AI Cost Tracking

![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.5-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.73-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-3.3h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)

- 🤖 **LLM usage:** $0.7300 (4 commits)
- 👤 **Human dev:** ~$332 (3.3h @ $100/h, 30min dedup)

Generated on 2026-07-06 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)

---

Narzędzie do wykrywania i refaktoryzacji hardkodowanych wartości, struktur danych i kodu w projektach Python.

## Co robi

- **scan** — wykrywa magic numbers, długie stringi, osadzone słowniki/listy, powtarzające się literały
- **extract** — wyciąga hardkod do modułu stałych (`constants.py` lub wskazany plik)
- **split** — rozbija duże struktury (dict/list) na mniejsze nazwane fragmenty
- **move** — przenosi stałe między modułami i aktualizuje importy
- **remove** — usuwa nieużywane stałe modułowe
- **apply** — stosuje plan refaktoryzacji (YAML/JSON)

## Instalacja

```bash
cd ~/github/semcod/reko
pip install -e ".[apply,dev]"
```

## Użycie

```bash
# skan projektu
reko scan .

# skan z raportem JSON
reko scan src/ --format json -o report.json

# wyciągnij hardkod do constants.py (dry-run)
reko extract src/ --target src/myapp/constants.py --dry-run

# rozbij dużą strukturę w pliku
reko split src/config.py --min-keys 5

# przenieś stałe
reko move src/old.py src/new_constants.py --names TIMEOUT,API_URL

# usuń nieużywane stałe
reko remove src/constants.py --dry-run

# zastosuj plan
reko apply plan.yaml
```

## Konfiguracja

Plik `reko.yaml` w katalogu projektu:

```yaml
scan:
  extensions: [".py"]
  exclude:
    - "**/tests/**"
    - "**/__pycache__/**"
  min_string_length: 8
  min_dict_keys: 4
  allowed_numbers: [0, 1, -1, 2, 10, 100, 1000]

extract:
  target: "constants.py"
  naming: "upper_snake"
  group_by: "file"  # file | kind | none
```

## API

```python
from pathlib import Path
from reko import scan_project, extract_constants, apply_plan

findings = scan_project(Path("src/"))
result = extract_constants(Path("src/app.py"), target=Path("src/constants.py"))
```

## Licencja

Apache-2.0
