codex-bot 0.1.0__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 (129) hide show
  1. codex_bot-0.1.0/.claude/project.md +25 -0
  2. codex_bot-0.1.0/.claude/settings.local.json +10 -0
  3. codex_bot-0.1.0/.github/workflows/docs.yml +39 -0
  4. codex_bot-0.1.0/.gitignore +68 -0
  5. codex_bot-0.1.0/.pre-commit-config.yaml +38 -0
  6. codex_bot-0.1.0/CHANGELOG.md +29 -0
  7. codex_bot-0.1.0/CLAUDE.md +48 -0
  8. codex_bot-0.1.0/LICENSE +21 -0
  9. codex_bot-0.1.0/PKG-INFO +116 -0
  10. codex_bot-0.1.0/README.md +71 -0
  11. codex_bot-0.1.0/docs/DOCUMENTATION_STANDARD.md +142 -0
  12. codex_bot-0.1.0/docs/README.md +36 -0
  13. codex_bot-0.1.0/docs/api/README.md +3 -0
  14. codex_bot-0.1.0/docs/api/animation.md +9 -0
  15. codex_bot-0.1.0/docs/api/base.md +21 -0
  16. codex_bot-0.1.0/docs/api/cli.md +20 -0
  17. codex_bot-0.1.0/docs/api/director.md +13 -0
  18. codex_bot-0.1.0/docs/api/discovery.md +5 -0
  19. codex_bot-0.1.0/docs/api/factory.md +5 -0
  20. codex_bot-0.1.0/docs/api/fsm.md +22 -0
  21. codex_bot-0.1.0/docs/api/helper.md +5 -0
  22. codex_bot-0.1.0/docs/api/http.md +11 -0
  23. codex_bot-0.1.0/docs/api/middlewares.md +19 -0
  24. codex_bot-0.1.0/docs/api/redis.md +19 -0
  25. codex_bot-0.1.0/docs/api/router_builder.md +9 -0
  26. codex_bot-0.1.0/docs/api/sender.md +17 -0
  27. codex_bot-0.1.0/docs/api/url_signer.md +7 -0
  28. codex_bot-0.1.0/docs/en_EN/README.md +36 -0
  29. codex_bot-0.1.0/docs/en_EN/architecture/animation/README.md +39 -0
  30. codex_bot-0.1.0/docs/en_EN/architecture/base/README.md +38 -0
  31. codex_bot-0.1.0/docs/en_EN/architecture/cli/README.md +38 -0
  32. codex_bot-0.1.0/docs/en_EN/architecture/director/README.md +39 -0
  33. codex_bot-0.1.0/docs/en_EN/architecture/engine/README.md +41 -0
  34. codex_bot-0.1.0/docs/en_EN/architecture/fsm/README.md +38 -0
  35. codex_bot-0.1.0/docs/en_EN/architecture/helper/README.md +37 -0
  36. codex_bot-0.1.0/docs/en_EN/architecture/redis/README.md +40 -0
  37. codex_bot-0.1.0/docs/en_EN/architecture/sender/README.md +41 -0
  38. codex_bot-0.1.0/docs/en_EN/architecture/url_signer/README.md +38 -0
  39. codex_bot-0.1.0/docs/guide/getting_started.md +20 -0
  40. codex_bot-0.1.0/docs/ru_RU/README.md +36 -0
  41. codex_bot-0.1.0/docs/ru_RU/architecture/animation/README.md +39 -0
  42. codex_bot-0.1.0/docs/ru_RU/architecture/base/README.md +38 -0
  43. codex_bot-0.1.0/docs/ru_RU/architecture/cli/README.md +38 -0
  44. codex_bot-0.1.0/docs/ru_RU/architecture/director/README.md +39 -0
  45. codex_bot-0.1.0/docs/ru_RU/architecture/engine/README.md +41 -0
  46. codex_bot-0.1.0/docs/ru_RU/architecture/fsm/README.md +38 -0
  47. codex_bot-0.1.0/docs/ru_RU/architecture/helper/README.md +37 -0
  48. codex_bot-0.1.0/docs/ru_RU/architecture/redis/README.md +40 -0
  49. codex_bot-0.1.0/docs/ru_RU/architecture/sender/README.md +41 -0
  50. codex_bot-0.1.0/docs/ru_RU/architecture/url_signer/README.md +38 -0
  51. codex_bot-0.1.0/mkdocs.yml +67 -0
  52. codex_bot-0.1.0/project_structure.txt +207 -0
  53. codex_bot-0.1.0/pyproject.toml +85 -0
  54. codex_bot-0.1.0/src/codex_bot/__init__.py +24 -0
  55. codex_bot-0.1.0/src/codex_bot/animation/__init__.py +10 -0
  56. codex_bot-0.1.0/src/codex_bot/animation/animation_service.py +298 -0
  57. codex_bot-0.1.0/src/codex_bot/base/__init__.py +22 -0
  58. codex_bot-0.1.0/src/codex_bot/base/base_orchestrator.py +123 -0
  59. codex_bot-0.1.0/src/codex_bot/base/context_dto.py +42 -0
  60. codex_bot-0.1.0/src/codex_bot/base/view_dto.py +93 -0
  61. codex_bot-0.1.0/src/codex_bot/cli/__init__.py +11 -0
  62. codex_bot-0.1.0/src/codex_bot/cli/commands.py +215 -0
  63. codex_bot-0.1.0/src/codex_bot/director/__init__.py +13 -0
  64. codex_bot-0.1.0/src/codex_bot/director/director.py +107 -0
  65. codex_bot-0.1.0/src/codex_bot/director/protocols.py +80 -0
  66. codex_bot-0.1.0/src/codex_bot/engine/__init__.py +13 -0
  67. codex_bot-0.1.0/src/codex_bot/engine/discovery/__init__.py +7 -0
  68. codex_bot-0.1.0/src/codex_bot/engine/discovery/service.py +258 -0
  69. codex_bot-0.1.0/src/codex_bot/engine/factory/__init__.py +7 -0
  70. codex_bot-0.1.0/src/codex_bot/engine/factory/bot_builder.py +111 -0
  71. codex_bot-0.1.0/src/codex_bot/engine/http/__init__.py +10 -0
  72. codex_bot-0.1.0/src/codex_bot/engine/http/api_client.py +123 -0
  73. codex_bot-0.1.0/src/codex_bot/engine/i18n/__init__.py +7 -0
  74. codex_bot-0.1.0/src/codex_bot/engine/i18n/locales_compiler.py +83 -0
  75. codex_bot-0.1.0/src/codex_bot/engine/middlewares/__init__.py +24 -0
  76. codex_bot-0.1.0/src/codex_bot/engine/middlewares/container.py +46 -0
  77. codex_bot-0.1.0/src/codex_bot/engine/middlewares/i18n.py +90 -0
  78. codex_bot-0.1.0/src/codex_bot/engine/middlewares/throttling.py +69 -0
  79. codex_bot-0.1.0/src/codex_bot/engine/middlewares/user_validation.py +49 -0
  80. codex_bot-0.1.0/src/codex_bot/engine/router_builder/__init__.py +10 -0
  81. codex_bot-0.1.0/src/codex_bot/engine/router_builder/router_builder.py +133 -0
  82. codex_bot-0.1.0/src/codex_bot/fsm/__init__.py +16 -0
  83. codex_bot-0.1.0/src/codex_bot/fsm/common_fsm_handlers.py +46 -0
  84. codex_bot-0.1.0/src/codex_bot/fsm/garbage_collector.py +141 -0
  85. codex_bot-0.1.0/src/codex_bot/fsm/state_helper.py +72 -0
  86. codex_bot-0.1.0/src/codex_bot/fsm/state_manager.py +104 -0
  87. codex_bot-0.1.0/src/codex_bot/helper/__init__.py +7 -0
  88. codex_bot-0.1.0/src/codex_bot/helper/context_helper.py +61 -0
  89. codex_bot-0.1.0/src/codex_bot/redis/__init__.py +15 -0
  90. codex_bot-0.1.0/src/codex_bot/redis/dispatcher.py +169 -0
  91. codex_bot-0.1.0/src/codex_bot/redis/router.py +71 -0
  92. codex_bot-0.1.0/src/codex_bot/redis/stream_processor.py +210 -0
  93. codex_bot-0.1.0/src/codex_bot/sender/__init__.py +15 -0
  94. codex_bot-0.1.0/src/codex_bot/sender/protocols.py +67 -0
  95. codex_bot-0.1.0/src/codex_bot/sender/sender_keys.py +50 -0
  96. codex_bot-0.1.0/src/codex_bot/sender/sender_manager.py +85 -0
  97. codex_bot-0.1.0/src/codex_bot/sender/view_sender.py +200 -0
  98. codex_bot-0.1.0/src/codex_bot/templates/feature/callbacks.py.tpl +14 -0
  99. codex_bot-0.1.0/src/codex_bot/templates/feature/contract.py.tpl +12 -0
  100. codex_bot-0.1.0/src/codex_bot/templates/feature/dto.py.tpl +7 -0
  101. codex_bot-0.1.0/src/codex_bot/templates/feature/feature.py.tpl +26 -0
  102. codex_bot-0.1.0/src/codex_bot/templates/feature/feature_redis.py.tpl +6 -0
  103. codex_bot-0.1.0/src/codex_bot/templates/feature/formatters.py.tpl +15 -0
  104. codex_bot-0.1.0/src/codex_bot/templates/feature/handlers.py.tpl +32 -0
  105. codex_bot-0.1.0/src/codex_bot/templates/feature/handlers_redis.py.tpl +24 -0
  106. codex_bot-0.1.0/src/codex_bot/templates/feature/keyboards.py.tpl +14 -0
  107. codex_bot-0.1.0/src/codex_bot/templates/feature/orchestrator.py.tpl +26 -0
  108. codex_bot-0.1.0/src/codex_bot/templates/feature/orchestrator_redis.py.tpl +17 -0
  109. codex_bot-0.1.0/src/codex_bot/templates/feature/texts.py.tpl +6 -0
  110. codex_bot-0.1.0/src/codex_bot/templates/feature/ui.py.tpl +19 -0
  111. codex_bot-0.1.0/src/codex_bot/url_signer/__init__.py +7 -0
  112. codex_bot-0.1.0/src/codex_bot/url_signer/service.py +116 -0
  113. codex_bot-0.1.0/tests/animation/test_animation_service.py +55 -0
  114. codex_bot-0.1.0/tests/base/test_base_orchestrator.py +54 -0
  115. codex_bot-0.1.0/tests/base/test_view_dto.py +48 -0
  116. codex_bot-0.1.0/tests/conftest.py +42 -0
  117. codex_bot-0.1.0/tests/director/test_director.py +54 -0
  118. codex_bot-0.1.0/tests/engine/factory/test_bot_builder.py +37 -0
  119. codex_bot-0.1.0/tests/engine/http/test_api_client.py +60 -0
  120. codex_bot-0.1.0/tests/engine/middlewares/test_throttling.py +62 -0
  121. codex_bot-0.1.0/tests/fsm/test_garbage_collector.py +50 -0
  122. codex_bot-0.1.0/tests/fsm/test_state_manager.py +48 -0
  123. codex_bot-0.1.0/tests/helper/test_context_helper.py +47 -0
  124. codex_bot-0.1.0/tests/sender/test_sender_keys.py +16 -0
  125. codex_bot-0.1.0/tests/url_signer/test_url_signer.py +49 -0
  126. codex_bot-0.1.0/tools/__init__.py +0 -0
  127. codex_bot-0.1.0/tools/dev/__init__.py +0 -0
  128. codex_bot-0.1.0/tools/dev/check.py +245 -0
  129. codex_bot-0.1.0/tools/dev/generate_project_tree.py +119 -0
@@ -0,0 +1,25 @@
1
+ # codex-bot β€” agent quick reference
2
+
3
+ ## Memory
4
+ `C:\Users\prime\.claude\projects\C--install-progect-codex-bot\memory\MEMORY.md`
5
+
6
+ ## Project
7
+ - Package: `C:/install/progect/codex_bot/`
8
+ - Source: `C:/install/progect/lily_website/src/telegram_bot/`
9
+ - Status: всС ΠΌΠΎΠ΄ΡƒΠ»ΠΈ Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹, ΠΈΠ΄Ρ‘Ρ‚ code review
10
+
11
+ ## Dev commands
12
+ ```bash
13
+ cd C:/install/progect/codex_bot
14
+ mkdocs build --strict # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ
15
+ ruff check src/ # Π»ΠΈΠ½Ρ‚ΠΈΠ½Π³
16
+ mypy src/ # Ρ‚ΠΈΠΏΡ‹
17
+ python -c "import codex_bot; print('ok')"
18
+ ```
19
+
20
+ ## Key conventions
21
+ - ВсС DTO: `frozen=True`, ΠΌΡƒΡ‚Π°Ρ†ΠΈΠΈ Ρ‡Π΅Ρ€Π΅Π· `model_copy(update=...)`
22
+ - ΠžΡ€ΠΊΠ΅ΡΡ‚Ρ€Π°Ρ‚ΠΎΡ€Ρ‹: stateless singleton, `Generic[PayloadT]`
23
+ - Redis: SET NX (Π°Ρ‚ΠΎΠΌΠ°Ρ€Π½ΠΎ), Π½Π΅ EXISTS + SET
24
+ - ImportError: провСряСм `e.name == module_path` (ΡƒΠΌΠ½Ρ‹ΠΉ Fail Fast)
25
+ - engine/ = инфраструктура "ΠΏΠΎΠ΄ ΠΊΠ°ΠΏΠΎΡ‚ΠΎΠΌ", Π½Π΅ ΠΏΡƒΠ±Π»ΠΈΡ‡Π½Ρ‹ΠΉ API
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(pip install -e \".[docs]\" -q)",
5
+ "Bash(python -c \"from codex_bot.base import BaseBotOrchestrator, UnifiedViewDTO, ViewResultDTO, BaseBotContext, MenuViewDTO, MessageCoordsDTO; print\\(''OK:'', BaseBotOrchestrator, UnifiedViewDTO\\)\")",
6
+ "Bash(mkdocs build --strict)",
7
+ "Bash(pip show mkdocs mkdocs-material)"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,39 @@
1
+ name: Deploy Docs to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ deploy-docs:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Configure Git Credentials
23
+ run: |
24
+ git config user.name github-actions[bot]
25
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: "3.12"
31
+
32
+ - name: Install dependencies
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ pip install -e ".[docs,all]"
36
+
37
+ - name: Build and deploy docs
38
+ run: |
39
+ mkdocs gh-deploy --force
@@ -0,0 +1,68 @@
1
+ # --- Python Core ---
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ venv/
9
+ .venv/
10
+ ENV/
11
+
12
+ # --- Build & Distribution ---
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # --- Testing & Coverage ---
31
+ .tox/
32
+ .nox/
33
+ .coverage
34
+ .coverage.*
35
+ .cache
36
+ nosetests.xml
37
+ coverage.xml
38
+ *.cover
39
+ *.py.cover
40
+ .hypothesis/
41
+ .pytest_cache/
42
+ htmlcov/
43
+
44
+ # --- Documentation ---
45
+ site/
46
+ docs/_build/
47
+
48
+ # --- Linting & Typing ---
49
+ .mypy_cache/
50
+ .ruff_cache/
51
+ .dmypy.json
52
+ dmypy.json
53
+ .pyre/
54
+ .pytype/
55
+
56
+ # --- IDEs & Editors ---
57
+ .idea/
58
+ .vscode/
59
+ *.swp
60
+ *.swo
61
+ .DS_Store
62
+
63
+ # --- Project Specific ---
64
+ .env
65
+ .envrc
66
+ *.log
67
+ # Temporary files from LocalesCompiler (if they leak into root)
68
+ bot_locales_*
@@ -0,0 +1,38 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-json
9
+ - id: check-added-large-files
10
+ args: ['--maxkb=2000']
11
+ - id: check-merge-conflict
12
+
13
+ - repo: https://github.com/astral-sh/ruff-pre-commit
14
+ rev: v0.9.6
15
+ hooks:
16
+ - id: ruff
17
+ args: [--fix]
18
+ - id: ruff-format
19
+
20
+ - repo: https://github.com/igorshubovych/markdownlint-cli
21
+ rev: v0.44.0
22
+ hooks:
23
+ - id: markdownlint
24
+ args: ["--fix", "--disable", "MD013"]
25
+
26
+ - repo: https://github.com/PyCQA/bandit
27
+ rev: 1.8.2
28
+ hooks:
29
+ - id: bandit
30
+ args: ["-c", "pyproject.toml"]
31
+ additional_dependencies: ["bandit[toml]"]
32
+
33
+ # 2. Поиск "Π·Π°Π±Ρ‹Ρ‚Ρ‹Ρ…" сСкрСтов ΠΈ ΠΏΠ°Ρ€ΠΎΠ»Π΅ΠΉ (усилСнный)
34
+ - repo: https://github.com/Yelp/detect-secrets
35
+ rev: v1.5.0
36
+ hooks:
37
+ - id: detect-secrets
38
+ # Baseline will be added after manual creation
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-03-09
9
+
10
+ ### Added
11
+ - **Initial Library Release**: Migration and adaptation of core infrastructure from production projects into a reusable feature-based framework.
12
+ - **Feature-based Architecture**: Implementation of `BaseBotOrchestrator` and `Director` for stateless UI management.
13
+ - **Redis Integration**: Stream processing, consumer groups support, and Redis-based dispatching.
14
+ - **FSM Enhancements**: `GarbageStateRegistry` for automatic UI cleanup and advanced state management.
15
+ - **Unified View System**: `ViewSender` and `UnifiedViewDTO` for consistent message rendering across different platforms.
16
+ - **I18n Engine**: Custom Fluent-based locales compiler with isolation support.
17
+ - **CLI Tools**: Scaffolding templates for rapid feature development.
18
+ - **Multi-language Documentation**: Comprehensive guides and API references in English and Russian.
19
+ - **DevOps Infrastructure**: Pre-commit hooks, Ruff/Mypy configurations, and GitHub Actions for docs.
20
+ - **Final Polish**: Refined `Director` logic, `BotBuilder` factory, and `RouterBuilder` for better stability.
21
+ - **Enhanced State Management**: Improved `StateManager` and `FSM` handlers for more robust session control.
22
+ - **Redis Dispatcher Optimization**: Fine-tuned stream processing and error handling in `RedisDispatcher`.
23
+ - **Test Coverage**: Added comprehensive unit tests for all core modules.
24
+
25
+ ### Changed
26
+ - Refactored production code into a modular library structure.
27
+ - Standardized DTOs and protocols for better extensibility.
28
+ - Optimized Redis Stream processing for high-load scenarios.
29
+ - Improved type safety across the entire codebase (Mypy strict mode).
@@ -0,0 +1,48 @@
1
+ # codex-bot β€” AI Context
2
+
3
+ Feature-based Aiogram framework library. MIT license, public GitHub.
4
+
5
+ ---
6
+
7
+ ## Agent Memory
8
+
9
+ > **Memory directory:** `C:\Users\prime\.claude\projects\C--install-progect-codex-bot\memory\`
10
+ >
11
+ > АгСнт ΠΈΠ· любого ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°: Ρ‡ΠΈΡ‚Π°ΠΉ `MEMORY.md` Ρ‚Π°ΠΌ β€” это индСкс.
12
+ > Π”Π΅Ρ‚Π°Π»ΠΈ Π²: `architecture.md`, `modules.md`, `fixes.md`
13
+
14
+ ---
15
+
16
+ ## Π‘Ρ‚Ρ€ΡƒΠΊΡ‚ΡƒΡ€Π° ΠΏΠ°ΠΊΠ΅Ρ‚Π°
17
+
18
+ ```
19
+ src/codex_bot/
20
+ β”œβ”€β”€ base/ ← BaseBotOrchestrator[T] (ABC), UnifiedViewDTO, ViewResultDTO
21
+ β”œβ”€β”€ director/ ← Director, OrchestratorProtocol, ContainerProtocol, SceneConfig
22
+ β”œβ”€β”€ fsm/ ← BaseStateManager, GarbageStateRegistry, common_fsm_router
23
+ β”œβ”€β”€ sender/ ← ViewSender (stateless), SenderManager, SenderKeys
24
+ β”œβ”€β”€ redis/ ← RedisRouter, BotRedisDispatcher, RedisStreamProcessor
25
+ β”œβ”€β”€ animation/ ← UIAnimationService, AnimationType
26
+ β”œβ”€β”€ helper/ ← ContextHelper
27
+ β”œβ”€β”€ url_signer/ ← UrlSignerService
28
+ └── engine/ ← инфраструктура "ΠΏΠΎΠ΄ ΠΊΠ°ΠΏΠΎΡ‚ΠΎΠΌ"
29
+ β”œβ”€β”€ middlewares/ ← ThrottlingMiddleware, ContainerMiddleware, UserValidationMiddleware
30
+ β”œβ”€β”€ discovery/ ← FeatureDiscoveryService (service.py)
31
+ β”œβ”€β”€ factory/ ← BotBuilder (bot_builder.py)
32
+ β”œβ”€β”€ router_builder/ ← collect_feature_routers, build_main_router (router_builder.py)
33
+ β”œβ”€β”€ http/ ← BaseApiClient, ApiClientError (api_client.py)
34
+ └── i18n/ ← compile_locales (locales_compiler.py)
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Π‘Ρ‚Π°Π½Π΄Π°Ρ€Ρ‚Ρ‹ (ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ)
40
+
41
+ - **Packaging**: Hatchling, PEP 621
42
+ - **Docstrings**: Google style β€” Args / Returns / Example
43
+ - **Docs**: MkDocs Material + mkdocstrings
44
+ - **DTO**: `frozen=True, arbitrary_types_allowed=True`, ΠΌΡƒΡ‚Π°Ρ†ΠΈΠΈ Ρ‡Π΅Ρ€Π΅Π· `model_copy(update=...)`
45
+ - **ΠžΡ€ΠΊΠ΅ΡΡ‚Ρ€Π°Ρ‚ΠΎΡ€Ρ‹**: stateless `Generic[PayloadT]`, `director` явный Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚
46
+ - **Fail Fast**: ΡƒΠΌΠ½Ρ‹ΠΉ `except ImportError` (провСряСм `e.name == module_path`)
47
+ - **Redis**: SET NX вмСсто EXISTS + SET (Π°Ρ‚ΠΎΠΌΠ°Ρ€Π½ΠΎ, Π½Π΅Ρ‚ race condition)
48
+ - **SecurityMiddleware**: ΡƒΠ΄Π°Π»Ρ‘Π½ навсСгда (ΠΈΠ»Π»ΡŽΠ·ΠΎΡ€Π½Π°Ρ Π·Π°Ρ‰ΠΈΡ‚Π° + лишний HGETALL)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CodexDLC
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.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-bot
3
+ Version: 0.1.0
4
+ Summary: Feature-based Aiogram framework library β€” reusable infrastructure for Telegram bots
5
+ Author: Codex Team
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: aiogram,bot,framework,telegram
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Framework :: AsyncIO
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Communications :: Chat
15
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
16
+ Requires-Python: >=3.12
17
+ Requires-Dist: aiogram<4.0,>=3.4
18
+ Requires-Dist: pydantic<3.0,>=2.0
19
+ Provides-Extra: all
20
+ Requires-Dist: aiogram-i18n>=1.4; extra == 'all'
21
+ Requires-Dist: arq>=0.25; extra == 'all'
22
+ Requires-Dist: httpx<1.0,>=0.27; extra == 'all'
23
+ Requires-Dist: redis[asyncio]<6.0,>=5.0; extra == 'all'
24
+ Provides-Extra: arq
25
+ Requires-Dist: arq>=0.25; extra == 'arq'
26
+ Provides-Extra: dev
27
+ Requires-Dist: bandit>=1.7; extra == 'dev'
28
+ Requires-Dist: mypy>=1.10; extra == 'dev'
29
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
30
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
31
+ Requires-Dist: pytest-cov; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.4; extra == 'dev'
34
+ Provides-Extra: docs
35
+ Requires-Dist: mkdocs-material>=9.0; extra == 'docs'
36
+ Requires-Dist: mkdocs>=1.5; extra == 'docs'
37
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
38
+ Provides-Extra: http
39
+ Requires-Dist: httpx<1.0,>=0.27; extra == 'http'
40
+ Provides-Extra: i18n
41
+ Requires-Dist: aiogram-i18n>=1.4; extra == 'i18n'
42
+ Provides-Extra: redis
43
+ Requires-Dist: redis[asyncio]<6.0,>=5.0; extra == 'redis'
44
+ Description-Content-Type: text/markdown
45
+
46
+ # Codex Bot Framework
47
+
48
+ [![PyPI version](https://img.shields.io/pypi/v/codex-bot.svg)](https://pypi.org/project/codex-bot/)
49
+ [![Python versions](https://img.shields.io/pypi/pyversions/codex-bot.svg)](https://pypi.org/project/codex-bot/)
50
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
51
+
52
+ **Codex Bot** is a professional, feature-based framework built on top of [Aiogram 3.x](https://github.com/aiogram/aiogram). It provides a reusable, production-ready infrastructure for building complex, scalable Telegram bots with a focus on stateless UI management and high-load Redis integration.
53
+
54
+ ---
55
+
56
+ ## πŸš€ Key Features
57
+
58
+ - **Feature-based Architecture**: Organize your bot into independent, reusable features.
59
+ - **Stateless Orchestrators**: Manage UI logic without storing state in memory, making your bot horizontally scalable.
60
+ - **Redis Stream Integration**: Native support for high-load event processing with Consumer Groups.
61
+ - **Advanced FSM**: Automatic UI cleanup with `GarbageStateRegistry` and structured state management.
62
+ - **Unified View System**: Consistent message rendering across different platforms using DTOs.
63
+ - **Fluent-based I18n**: Powerful localization engine with project-level isolation and automatic compilation.
64
+ - **CLI Scaffolding**: Rapidly generate new features with pre-defined templates.
65
+
66
+ ---
67
+
68
+ ## πŸ“¦ Installation
69
+
70
+ Install the core library:
71
+ ```bash
72
+ pip install codex-bot
73
+ ```
74
+
75
+ Install with optional dependencies:
76
+ ```bash
77
+ pip install "codex-bot[redis,i18n,http]"
78
+ ```
79
+
80
+ ---
81
+
82
+ ## πŸ›  Quick Start
83
+
84
+ ```python
85
+ from codex_bot import BotBuilder, BaseBotOrchestrator, Director
86
+ from codex_bot.base.view_dto import ViewResultDTO
87
+
88
+ # 1. Define your feature orchestrator
89
+ class MyFeatureOrchestrator(BaseBotOrchestrator[None]):
90
+ async def render_content(self, payload: None, director: Director) -> ViewResultDTO:
91
+ return ViewResultDTO(text="Hello from Codex Bot!")
92
+
93
+ # 2. Build and run your bot
94
+ builder = BotBuilder(token="YOUR_TELEGRAM_TOKEN")
95
+ builder.register_orchestrator("main", MyFeatureOrchestrator())
96
+ builder.run_polling()
97
+ ```
98
+
99
+ ---
100
+
101
+ ## πŸ“š Documentation
102
+
103
+ - [English Documentation](https://codex-team.github.io/codex_bot/en_EN/)
104
+ - [Русская докумСнтация](https://codex-team.github.io/codex_bot/ru_RU/)
105
+ - [**Changelog**](CHANGELOG.md) β€” see what's new in the latest versions.
106
+
107
+ ---
108
+
109
+ ## πŸ“„ License
110
+
111
+ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
112
+
113
+ ---
114
+
115
+ ### πŸ‡·πŸ‡Ί ΠšΡ€Π°Ρ‚ΠΊΠΎΠ΅ описаниС (RU)
116
+ **Codex Bot** β€” это ΠΏΡ€ΠΎΡ„Π΅ΡΡΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹ΠΉ Ρ„Ρ€Π΅ΠΉΠΌΠ²ΠΎΡ€ΠΊ для создания Telegram-Π±ΠΎΡ‚ΠΎΠ² Π½Π° Π±Π°Π·Π΅ Aiogram 3.x. Он прСдоставляСт Π³ΠΎΡ‚ΠΎΠ²ΡƒΡŽ инфраструктуру для Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ слоТных ΠΈ ΠΌΠ°ΡΡˆΡ‚Π°Π±ΠΈΡ€ΡƒΠ΅ΠΌΡ‹Ρ… систСм, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ Π°Ρ€Ρ…ΠΈΡ‚Π΅ΠΊΡ‚ΡƒΡ€Ρƒ Π½Π° основС "Ρ„ΠΈΡ‡", stateless-оркСстраторы ΠΈ Π³Π»ΡƒΠ±ΠΎΠΊΡƒΡŽ ΠΈΠ½Ρ‚Π΅Π³Ρ€Π°Ρ†ΠΈΡŽ с Redis Streams.
@@ -0,0 +1,71 @@
1
+ # Codex Bot Framework
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/codex-bot.svg)](https://pypi.org/project/codex-bot/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/codex-bot.svg)](https://pypi.org/project/codex-bot/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **Codex Bot** is a professional, feature-based framework built on top of [Aiogram 3.x](https://github.com/aiogram/aiogram). It provides a reusable, production-ready infrastructure for building complex, scalable Telegram bots with a focus on stateless UI management and high-load Redis integration.
8
+
9
+ ---
10
+
11
+ ## πŸš€ Key Features
12
+
13
+ - **Feature-based Architecture**: Organize your bot into independent, reusable features.
14
+ - **Stateless Orchestrators**: Manage UI logic without storing state in memory, making your bot horizontally scalable.
15
+ - **Redis Stream Integration**: Native support for high-load event processing with Consumer Groups.
16
+ - **Advanced FSM**: Automatic UI cleanup with `GarbageStateRegistry` and structured state management.
17
+ - **Unified View System**: Consistent message rendering across different platforms using DTOs.
18
+ - **Fluent-based I18n**: Powerful localization engine with project-level isolation and automatic compilation.
19
+ - **CLI Scaffolding**: Rapidly generate new features with pre-defined templates.
20
+
21
+ ---
22
+
23
+ ## πŸ“¦ Installation
24
+
25
+ Install the core library:
26
+ ```bash
27
+ pip install codex-bot
28
+ ```
29
+
30
+ Install with optional dependencies:
31
+ ```bash
32
+ pip install "codex-bot[redis,i18n,http]"
33
+ ```
34
+
35
+ ---
36
+
37
+ ## πŸ›  Quick Start
38
+
39
+ ```python
40
+ from codex_bot import BotBuilder, BaseBotOrchestrator, Director
41
+ from codex_bot.base.view_dto import ViewResultDTO
42
+
43
+ # 1. Define your feature orchestrator
44
+ class MyFeatureOrchestrator(BaseBotOrchestrator[None]):
45
+ async def render_content(self, payload: None, director: Director) -> ViewResultDTO:
46
+ return ViewResultDTO(text="Hello from Codex Bot!")
47
+
48
+ # 2. Build and run your bot
49
+ builder = BotBuilder(token="YOUR_TELEGRAM_TOKEN")
50
+ builder.register_orchestrator("main", MyFeatureOrchestrator())
51
+ builder.run_polling()
52
+ ```
53
+
54
+ ---
55
+
56
+ ## πŸ“š Documentation
57
+
58
+ - [English Documentation](https://codex-team.github.io/codex_bot/en_EN/)
59
+ - [Русская докумСнтация](https://codex-team.github.io/codex_bot/ru_RU/)
60
+ - [**Changelog**](CHANGELOG.md) β€” see what's new in the latest versions.
61
+
62
+ ---
63
+
64
+ ## πŸ“„ License
65
+
66
+ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
67
+
68
+ ---
69
+
70
+ ### πŸ‡·πŸ‡Ί ΠšΡ€Π°Ρ‚ΠΊΠΎΠ΅ описаниС (RU)
71
+ **Codex Bot** β€” это ΠΏΡ€ΠΎΡ„Π΅ΡΡΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹ΠΉ Ρ„Ρ€Π΅ΠΉΠΌΠ²ΠΎΡ€ΠΊ для создания Telegram-Π±ΠΎΡ‚ΠΎΠ² Π½Π° Π±Π°Π·Π΅ Aiogram 3.x. Он прСдоставляСт Π³ΠΎΡ‚ΠΎΠ²ΡƒΡŽ инфраструктуру для Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ слоТных ΠΈ ΠΌΠ°ΡΡˆΡ‚Π°Π±ΠΈΡ€ΡƒΠ΅ΠΌΡ‹Ρ… систСм, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ Π°Ρ€Ρ…ΠΈΡ‚Π΅ΠΊΡ‚ΡƒΡ€Ρƒ Π½Π° основС "Ρ„ΠΈΡ‡", stateless-оркСстраторы ΠΈ Π³Π»ΡƒΠ±ΠΎΠΊΡƒΡŽ ΠΈΠ½Ρ‚Π΅Π³Ρ€Π°Ρ†ΠΈΡŽ с Redis Streams.
@@ -0,0 +1,142 @@
1
+ # 🧭 Documentation Standard for codex-bot
2
+
3
+ > **AUTHORITY:** This document defines how documentation is written, structured, and maintained in the `codex-bot` library.
4
+
5
+ ---
6
+
7
+ ## 1. πŸ“œ Core Philosophy
8
+
9
+ We maintain documentation in **two languages** to ensure international accessibility while keeping the local community engaged.
10
+
11
+ ### πŸ‡¬πŸ‡§ English (Primary / Technical Truth)
12
+
13
+ - **Mandatory for:** All Pull Requests and technical specifications.
14
+ - **Location:**
15
+ - `docs/api/` β€” Technical API reference (auto-generated from docstrings).
16
+ - `docs/en_EN/` β€” Conceptual guides and architectural mirroring.
17
+ - **Content:**
18
+ - Full technical specifications.
19
+ - API documentation (via `docs/api/`).
20
+ - Code examples and integration guides.
21
+ - **Goal:** Single source of truth. If code contradicts EN docs, it is a bug.
22
+
23
+ ### πŸ‡·πŸ‡Ί Russian (Secondary / Conceptual Hub)
24
+
25
+ - **Optional for Contributors:** If you don't speak Russian, write EN docs. Maintainers will add RU translation.
26
+ - **Location:** `docs/ru_RU/` (mirrors folder structure).
27
+ - **Content:**
28
+ - Conceptual translation (the "why" and "how").
29
+ - Links to `docs/api/` for technical details instead of duplication.
30
+ - Architect's mental model and design decision explanations.
31
+ - **Goal:** Help Russian-speaking developers understand the "why" behind the framework's architecture.
32
+
33
+ ---
34
+
35
+ ## 2. ☯️ Twin Realms Principle
36
+
37
+ Documentation languages serve different purposes:
38
+
39
+ ### πŸ‡¬πŸ‡§ EN = Technical Truth
40
+
41
+ - **For:** AI generators, external libraries, standards compliance.
42
+ - **Format:** Granular (mirrors `src/codex_bot/` structure).
43
+ - **Contains:**
44
+ - API Reference (in `docs/api/`).
45
+ - Mermaid Diagrams (Sequence, Class, ER).
46
+ - Integration patterns.
47
+
48
+ ### πŸ‡·πŸ‡Ί RU = Architect's Mind
49
+
50
+ - **For:** Human developers, system understanding.
51
+ - **Format:** Aggregated (1 folder = 1 README).
52
+ - **Contains:**
53
+ - **The Why:** Why this solution (e.g., why Stateless Orchestrators) was chosen.
54
+ - **The Flow:** How data flows through the system (simplified).
55
+ - **Links:** References to `docs/api/` files for technical details.
56
+
57
+ ---
58
+
59
+ ## 3. πŸ—‚οΈ Structure Mirroring Rule
60
+
61
+ Documentation structure **MUST** mirror the code structure in `src/codex_bot/`.
62
+
63
+ ### Mapping Example
64
+
65
+ | Code Location | Documentation Location (EN/RU) |
66
+ |:---|:---|
67
+ | `src/codex_bot/base/` | `docs/[lang]/architecture/base/` |
68
+ | `src/codex_bot/engine/router_builder/` | `docs/[lang]/architecture/engine/router_builder/` |
69
+ | `src/codex_bot/redis/` | `docs/[lang]/architecture/redis/` |
70
+
71
+ ### Why?
72
+
73
+ - **1:1 Mapping:** Easy to find docs for any code module.
74
+ - **No Orphans:** Prevents documentation from getting lost.
75
+ - **Refactoring Safety:** When code moves, docs move with it.
76
+
77
+ ---
78
+
79
+ ## 4. 🧭 Navigation Standard
80
+
81
+ Every documentation file must be easily navigable.
82
+
83
+ ### Breadcrumbs (Mandatory)
84
+
85
+ Every file **MUST** start with a navigation header:
86
+
87
+ ```markdown
88
+ [⬅️ Back](../README.md) | [🏠 Docs Root](../../README.md)
89
+ ```
90
+
91
+ - **Back:** Links to the current directory's `README.md`.
92
+ - **Docs Root:** Links to the documentation root (`docs/README.md`).
93
+
94
+ ### Index Files (README.md)
95
+
96
+ Every directory **MUST** have a `README.md` acting as a navigation hub.
97
+
98
+ **Required Structure:**
99
+
100
+ 1. **Header:** Emoji πŸ“‚ + Section Name.
101
+ 2. **Navigation:** Breadcrumbs.
102
+ 3. **Description:** Short summary (2-3 sentences).
103
+ 4. **Map:** Table or list of files in **logical reading order** (not alphabetical).
104
+
105
+ ---
106
+
107
+ ## 5. πŸ“ File Naming & Organization
108
+
109
+ ### Naming Conventions
110
+
111
+ - **Format:** `snake_case.md` (e.g., `orchestrator_logic.md`).
112
+ - **No Prefixes:** Do NOT use `01_`, `02_` prefixes in filenames.
113
+ - **Reading Order:** Defined in `README.md` map.
114
+
115
+ ### Language Folders
116
+
117
+ All documents **MUST** reside in:
118
+
119
+ - `docs/api/` (Technical EN)
120
+ - `docs/en_EN/` (Conceptual EN)
121
+ - `docs/ru_RU/` (Conceptual RU)
122
+
123
+ ---
124
+
125
+ ## 6. βœ… Markdown Linting Rules (Strict)
126
+
127
+ 1. **MD047 (End with Newline):** Every file must end with exactly **one newline** (`\n`).
128
+ 2. **MD032 (List Spacing):** Blank line before and after any list.
129
+ 3. **MD007 (Indentation):** Use **2 spaces** for nested lists.
130
+
131
+ ---
132
+
133
+ ## 7. 🚫 Common Mistakes
134
+
135
+ - **❌ Duplicating Code in RU Docs:** Link to `docs/api/` instead.
136
+ - **❌ Numbered Prefixes:** Use `README.md` map for order.
137
+ - **❌ Missing Breadcrumbs:** Always add the navigation header.
138
+ - **❌ Language-neutral folders:** Use `en_EN` or `ru_RU`.
139
+
140
+ ---
141
+
142
+ **Last Updated:** 2025-02-07
@@ -0,0 +1,36 @@
1
+ # πŸ€– codex-bot Documentation
2
+
3
+ Welcome to the official documentation for `codex-bot` β€” a feature-based Aiogram framework library for building scalable Telegram bots.
4
+
5
+ ---
6
+
7
+ ## 🌍 Choose Your Language
8
+
9
+ | Language | Description |
10
+ |:---|:---|
11
+ | **[πŸ‡¬πŸ‡§ English](./en_EN/README.md)** | Primary documentation, conceptual guides, and architecture. |
12
+ | **[πŸ‡·πŸ‡Ί Русский](./ru_RU/README.md)** | Conceptual translation and architect's mental model. |
13
+
14
+ ---
15
+
16
+ ## πŸ“„ Technical Reference
17
+
18
+ | Section | Description |
19
+ |:---|:---|
20
+ | **[πŸ› οΈ API Reference](./api/README.md)** | Full technical API documentation generated from code docstrings. |
21
+ | **[🧭 Documentation Standard](./DOCUMENTATION_STANDARD.md)** | How we write and structure documentation in this project. |
22
+
23
+ ---
24
+
25
+ ## πŸš€ Quick Install
26
+
27
+ ```bash
28
+ pip install codex-bot # core only
29
+ pip install codex-bot[redis] # + Redis support
30
+ pip install codex-bot[redis,arq,i18n] # + background tasks + i18n
31
+ pip install codex-bot[all] # everything
32
+ ```
33
+
34
+ ---
35
+
36
+ **Last Updated:** 2025-02-07
@@ -0,0 +1,3 @@
1
+ # API Reference
2
+
3
+ Full API reference for `codex-bot` library modules.
@@ -0,0 +1,9 @@
1
+ # animation β€” Waiting animation for Telegram UI
2
+
3
+ ## UIAnimationService
4
+
5
+ ::: codex_bot.animation.animation_service.UIAnimationService
6
+
7
+ ## AnimationType
8
+
9
+ ::: codex_bot.animation.animation_service.AnimationType