codex-core 0.1.1__tar.gz → 0.2.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.
- {codex_core-0.1.1 → codex_core-0.2.0}/.github/workflows/ci.yml +6 -3
- codex_core-0.2.0/.github/workflows/docs.yml +72 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/CHANGELOG.md +31 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/PKG-INFO +47 -20
- codex_core-0.2.0/README.md +63 -0
- {codex_core-0.1.1/docs/en_EN → codex_core-0.2.0/docs/en}/README.md +3 -3
- {codex_core-0.1.1/docs → codex_core-0.2.0/docs/en}/api/common.md +1 -1
- {codex_core-0.1.1/docs → codex_core-0.2.0/docs/en}/api/core.md +1 -1
- codex_core-0.2.0/docs/en/api/dev.md +29 -0
- {codex_core-0.1.1/docs → codex_core-0.2.0/docs/en}/api/index.md +2 -1
- {codex_core-0.1.1/docs → codex_core-0.2.0/docs/en}/api/settings.md +1 -1
- {codex_core-0.1.1/docs/en_EN → codex_core-0.2.0/docs/en}/architecture/README.md +1 -1
- {codex_core-0.1.1/docs/en_EN → codex_core-0.2.0/docs/en}/architecture/platform/common.md +1 -1
- {codex_core-0.1.1/docs/en_EN → codex_core-0.2.0/docs/en}/architecture/platform/core.md +1 -1
- codex_core-0.2.0/docs/en/architecture/platform/dev.md +225 -0
- {codex_core-0.1.1/docs/en_EN → codex_core-0.2.0/docs/en}/architecture/platform/settings.md +1 -1
- {codex_core-0.1.1 → codex_core-0.2.0}/docs/evolution/roadmap.md +1 -1
- {codex_core-0.1.1 → codex_core-0.2.0}/docs/index.md +4 -4
- {codex_core-0.1.1/docs/ru_RU → codex_core-0.2.0/docs/ru}/README.md +3 -3
- {codex_core-0.1.1/docs/ru_RU → codex_core-0.2.0/docs/ru}/architecture/README.md +1 -1
- {codex_core-0.1.1/docs/ru_RU → codex_core-0.2.0/docs/ru}/architecture/platform/common.md +1 -1
- {codex_core-0.1.1/docs/ru_RU → codex_core-0.2.0/docs/ru}/architecture/platform/core.md +1 -1
- codex_core-0.2.0/docs/ru/architecture/platform/dev.md +225 -0
- {codex_core-0.1.1/docs/ru_RU → codex_core-0.2.0/docs/ru}/architecture/platform/settings.md +1 -1
- {codex_core-0.1.1 → codex_core-0.2.0}/mkdocs.yml +28 -18
- codex_core-0.2.0/project_structure.txt +97 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/pyproject.toml +22 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/common/loguru_setup.py +3 -9
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/core/base_dto.py +1 -2
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/core/pii.py +8 -6
- codex_core-0.2.0/src/codex_core/dev/check_runner.py +201 -0
- codex_core-0.2.0/src/codex_core/dev/project_tree.py +128 -0
- codex_core-0.2.0/src/codex_core/dev/static_compiler/__init__.py +18 -0
- codex_core-0.2.0/src/codex_core/dev/static_compiler/compiler.py +166 -0
- codex_core-0.2.0/src/codex_core/dev/static_compiler/css.py +70 -0
- codex_core-0.2.0/src/codex_core/dev/static_compiler/js.py +56 -0
- codex_core-0.2.0/tests/conftest.py +21 -0
- codex_core-0.2.0/tests/integration/conftest.py +7 -0
- codex_core-0.2.0/tests/unit/common/test_log_context.py +53 -0
- codex_core-0.2.0/tests/unit/common/test_loguru_setup.py +140 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/common/test_text.py +5 -0
- codex_core-0.2.0/tests/unit/conftest.py +7 -0
- codex_core-0.2.0/tests/unit/core/test_exceptions.py +16 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/core/test_pii.py +32 -1
- codex_core-0.2.0/tools/__init__.py +0 -0
- codex_core-0.2.0/tools/dev/__init__.py +0 -0
- codex_core-0.2.0/tools/dev/check.py +14 -0
- codex_core-0.2.0/tools/dev/generate_project_tree.py +8 -0
- codex_core-0.1.1/.github/workflows/docs.yml +0 -46
- codex_core-0.1.1/README.md +0 -38
- codex_core-0.1.1/tests/conftest.py +0 -1
- codex_core-0.1.1/tools/dev/check.py +0 -197
- codex_core-0.1.1/tools/dev/generate_project_tree.py +0 -119
- {codex_core-0.1.1 → codex_core-0.2.0}/.github/workflows/publish.yml +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/.gitignore +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/.pre-commit-config.yaml +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/docs/changelog.md +0 -0
- {codex_core-0.1.1/docs/en_EN/guide → codex_core-0.2.0/docs/en/tasks}/getting_started.md +0 -0
- {codex_core-0.1.1/docs/ru_RU/guide → codex_core-0.2.0/docs/ru/tasks}/getting_started.md +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/common/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/common/log_context.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/common/phone.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/common/text.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/core/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/core/exceptions.py +0 -0
- {codex_core-0.1.1/tests/unit → codex_core-0.2.0/src/codex_core/dev}/__init__.py +0 -0
- /codex_core-0.1.1/tools/__init__.py → /codex_core-0.2.0/src/codex_core/py.typed +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/settings/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/src/codex_core/settings/base.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/integration/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/integration/test_settings_integration.py +0 -0
- {codex_core-0.1.1/tools/dev → codex_core-0.2.0/tests/unit}/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/common/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/common/test_phone.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/core/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/settings/__init__.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tests/unit/settings/test_settings.py +0 -0
- {codex_core-0.1.1 → codex_core-0.2.0}/tools/dev/README.md +0 -0
|
@@ -36,15 +36,18 @@ jobs:
|
|
|
36
36
|
run: pip install mypy && mypy src/codex_core/
|
|
37
37
|
|
|
38
38
|
unit-tests:
|
|
39
|
-
name: Unit Tests
|
|
39
|
+
name: Unit Tests (Python ${{ matrix.python-version }})
|
|
40
40
|
needs: quality-gate
|
|
41
41
|
runs-on: ubuntu-latest
|
|
42
|
+
strategy:
|
|
43
|
+
matrix:
|
|
44
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
42
45
|
steps:
|
|
43
46
|
- uses: actions/checkout@v4
|
|
44
|
-
- name: Set up Python
|
|
47
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
45
48
|
uses: actions/setup-python@v5
|
|
46
49
|
with:
|
|
47
|
-
python-version:
|
|
50
|
+
python-version: ${{ matrix.python-version }}
|
|
48
51
|
cache: 'pip'
|
|
49
52
|
|
|
50
53
|
- name: Install All Dependencies
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: Deploy Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
version:
|
|
10
|
+
description: 'Version alias to deploy (e.g. 0.x, 1.x)'
|
|
11
|
+
required: true
|
|
12
|
+
alias:
|
|
13
|
+
description: 'Alias (latest, stable, or leave empty)'
|
|
14
|
+
required: false
|
|
15
|
+
default: 'latest'
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
19
|
+
|
|
20
|
+
permissions:
|
|
21
|
+
contents: write
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
deploy:
|
|
25
|
+
name: Build & Deploy Docs
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- name: Checkout code
|
|
29
|
+
uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
|
|
33
|
+
- name: Configure Git Credentials
|
|
34
|
+
run: |
|
|
35
|
+
git config user.name github-actions[bot]
|
|
36
|
+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
37
|
+
|
|
38
|
+
- name: Set up Python 3.12
|
|
39
|
+
uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: "3.12"
|
|
42
|
+
cache: 'pip'
|
|
43
|
+
|
|
44
|
+
- name: Install dependencies
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install --upgrade pip
|
|
47
|
+
pip install -e ".[docs]"
|
|
48
|
+
|
|
49
|
+
- name: Resolve version alias (tag push)
|
|
50
|
+
if: github.event_name == 'push'
|
|
51
|
+
id: version
|
|
52
|
+
run: |
|
|
53
|
+
TAG="${GITHUB_REF_NAME}" # e.g. v1.2.3
|
|
54
|
+
MAJOR=$(echo "$TAG" | sed 's/^v//' | cut -d. -f1)
|
|
55
|
+
MINOR=$(echo "$TAG" | sed 's/^v//' | cut -d. -f2)
|
|
56
|
+
echo "alias=${MAJOR}.x" >> "$GITHUB_OUTPUT"
|
|
57
|
+
|
|
58
|
+
- name: Deploy versioned docs (tag push)
|
|
59
|
+
if: github.event_name == 'push'
|
|
60
|
+
run: |
|
|
61
|
+
mike deploy --push --update-aliases "${{ steps.version.outputs.alias }}" latest
|
|
62
|
+
mike set-default --push latest
|
|
63
|
+
|
|
64
|
+
- name: Deploy versioned docs (manual)
|
|
65
|
+
if: github.event_name == 'workflow_dispatch'
|
|
66
|
+
run: |
|
|
67
|
+
if [ -n "${{ inputs.alias }}" ]; then
|
|
68
|
+
mike deploy --push --update-aliases "${{ inputs.version }}" "${{ inputs.alias }}"
|
|
69
|
+
else
|
|
70
|
+
mike deploy --push "${{ inputs.version }}"
|
|
71
|
+
fi
|
|
72
|
+
mike set-default --push latest
|
|
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2025-02-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Python 3.13 Support**: Added official support for Python 3.13 in `pyproject.toml` classifiers.
|
|
12
|
+
- **Comprehensive Unit Tests**:
|
|
13
|
+
- New tests for `core/exceptions.py` covering base exception functionality.
|
|
14
|
+
- New tests for `common/log_context.py` covering `TaskLogContext` logging methods.
|
|
15
|
+
- New tests for `common/loguru_setup.py` covering `InterceptHandler`, `setup_universal_logging`, and `setup_logging` with and without `loguru` installed.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **Documentation Structure**:
|
|
19
|
+
- Renamed top-level language directories from `en_EN/` to `en/` and `ru_RU/` to `ru/`.
|
|
20
|
+
- Moved `api/` documentation into `en/api/` for better language-specific grouping.
|
|
21
|
+
- Renamed `guide/` directories to `tasks/` in both `en/` and `ru/` to align with `DocArchitect:StructurePolicy` for user-oriented guides.
|
|
22
|
+
- Updated `mkdocs.yml` navigation and all internal Markdown links to reflect the new documentation structure.
|
|
23
|
+
- Updated root `README.md` to strictly follow `DocArchitect:StructurePolicy` (Layer 5 - Root Landing), including a detailed `Modules` table (with `dev` module) and a comprehensive `Part of the Codex ecosystem` section.
|
|
24
|
+
- **Test Coverage Configuration**:
|
|
25
|
+
- Configured `pytest-cov` in `pyproject.toml` to include `addopts`, `[tool.coverage.run]`, and `[tool.coverage.report]` sections.
|
|
26
|
+
- Excluded `src/codex_core/dev/*` from coverage reports as these are internal development tools.
|
|
27
|
+
- Added `exclude_lines` for `TYPE_CHECKING` and `ImportError` to achieve accurate coverage metrics.
|
|
28
|
+
- **Test Isolation**: Implemented `autouse` fixture `reset_pii_registry` in `tests/conftest.py` to ensure `PIIRegistry` global state is reset between tests, guaranteeing test isolation.
|
|
29
|
+
- **Test Markers**: Created `tests/unit/conftest.py` and `tests/integration/conftest.py` to automatically apply `pytest.mark.unit` and `pytest.mark.integration` markers to tests within their respective directories.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
- **Mypy Errors**: Resolved missing type parameters for generic types in `src/codex_core/dev/static_compiler/compiler.py` and `src/codex_core/dev/static_compiler/css.py`.
|
|
33
|
+
- **Ruff Errors**: Resolved `SIM118` (Use `key in dict` instead of `key in dict.keys()`) in `src/codex_core/core/pii.py`.
|
|
34
|
+
- **Ruff Errors**: Resolved `SIM117` (Use a single `with` statement with multiple contexts) in `tests/unit/common/test_loguru_setup.py`.
|
|
35
|
+
- **Test Coverage Gaps**:
|
|
36
|
+
- Covered `PIIRegistry` initialization logic and recursive list masking in `tests/unit/core/test_pii.py`.
|
|
37
|
+
- Covered falsy input handling in `transliterate` and `sanitize_for_sms` functions in `tests/unit/common/test_text.py`.
|
|
38
|
+
|
|
8
39
|
## [0.1.1] - 2025-02-12
|
|
9
40
|
|
|
10
41
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codex-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Core utilities, schemas and settings for Codex WaaS toolkit
|
|
5
5
|
Project-URL: Homepage, https://github.com/codexdlc/codex-core
|
|
6
6
|
Project-URL: Documentation, https://codexdlc.github.io/codex-core/
|
|
@@ -16,6 +16,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
21
|
Requires-Python: >=3.10
|
|
21
22
|
Requires-Dist: pydantic-settings>=2.0
|
|
@@ -31,6 +32,7 @@ Requires-Dist: pytest-cov; extra == 'dev'
|
|
|
31
32
|
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
33
|
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
33
34
|
Provides-Extra: docs
|
|
35
|
+
Requires-Dist: mike>=2.0; extra == 'docs'
|
|
34
36
|
Requires-Dist: mkdocs-include-markdown-plugin; extra == 'docs'
|
|
35
37
|
Requires-Dist: mkdocs-material>=9.0; extra == 'docs'
|
|
36
38
|
Requires-Dist: mkdocs>=1.5; extra == 'docs'
|
|
@@ -39,41 +41,66 @@ Provides-Extra: loguru
|
|
|
39
41
|
Requires-Dist: loguru>=0.7.0; extra == 'loguru'
|
|
40
42
|
Description-Content-Type: text/markdown
|
|
41
43
|
|
|
44
|
+
<!-- Type: LANDING -->
|
|
42
45
|
# codex-core
|
|
43
46
|
|
|
44
|
-
**Core utilities, schemas, and settings for the Codex WaaS toolkit.**
|
|
45
|
-
|
|
46
47
|
[](https://pypi.org/project/codex-core/)
|
|
47
48
|
[](https://pypi.org/project/codex-core/)
|
|
48
49
|
[](https://github.com/codexdlc/codex-core/blob/main/LICENSE)
|
|
49
50
|
[](https://codexdlc.github.io/codex-core/)
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
> **Documentation:**
|
|
54
|
-
> [EN](https://codexdlc.github.io/codex-core/en_EN/) · [RU](https://codexdlc.github.io/codex-core/ru_RU/) · [API Reference](https://codexdlc.github.io/codex-core/api/) · [Changelog](https://codexdlc.github.io/codex-core/changelog/)
|
|
52
|
+
Core utilities, immutable DTOs, and environment-driven settings for the Codex WaaS toolkit.
|
|
53
|
+
Provides the foundational building blocks and PII masking used by all other Codex components.
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* **Core Interfaces**: Base classes and protocols for Codex components.
|
|
59
|
-
* **Common Utilities**: Logger setup (Loguru), phone number validation, text processing, and caching.
|
|
60
|
-
* **Schemas**: Shared Pydantic models for cross-service communication.
|
|
61
|
-
* **Settings**: Modern configuration management using `pydantic-settings`.
|
|
55
|
+
---
|
|
62
56
|
|
|
63
|
-
##
|
|
57
|
+
## Install
|
|
64
58
|
|
|
65
59
|
```bash
|
|
60
|
+
# Core only
|
|
66
61
|
pip install codex-core
|
|
62
|
+
|
|
63
|
+
# With Loguru support for advanced structured logging
|
|
64
|
+
pip install "codex-core[loguru]"
|
|
67
65
|
```
|
|
68
66
|
|
|
69
|
-
##
|
|
67
|
+
## Quick Start
|
|
70
68
|
|
|
71
69
|
```python
|
|
72
|
-
from
|
|
70
|
+
from codex_core.core.base_dto import BaseDTO
|
|
71
|
+
|
|
72
|
+
# 1. Define an immutable, PII-aware data transfer object
|
|
73
|
+
class UserDTO(BaseDTO):
|
|
74
|
+
id: int
|
|
75
|
+
email: str # Automatically masked in logs
|
|
76
|
+
phone_number: str # Automatically masked in logs
|
|
77
|
+
|
|
78
|
+
user = UserDTO(id=42, email="user@example.com", phone_number="+491511234567")
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
# 2. Safely log the DTO without leaking personal data
|
|
81
|
+
print(user)
|
|
82
|
+
# Output: UserDTO(id=42, email='***', phone_number='***')
|
|
76
83
|
```
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
## Modules
|
|
86
|
+
|
|
87
|
+
| Module | Extra | Description |
|
|
88
|
+
| :--- | :--- | :--- |
|
|
89
|
+
| `codex_core.core` | - | Immutable `BaseDTO` and automated `PIIRegistry` for GDPR-safe logging. |
|
|
90
|
+
| `codex_core.common` | `[loguru]` | Phone/name normalization and structured logging adapters (`TaskLogContext`). |
|
|
91
|
+
| `codex_core.settings` | - | Environment-driven configuration via `BaseCommonSettings` (Pydantic Settings). |
|
|
92
|
+
| `codex_core.dev` | `[dev]` | Internal developer tools (`BaseCheckRunner`, `StaticCompiler`, `ProjectTreeGenerator`). |
|
|
93
|
+
|
|
94
|
+
## Documentation
|
|
95
|
+
|
|
96
|
+
Full docs with architecture, API reference, and data flow diagrams:
|
|
97
|
+
|
|
98
|
+
**[https://codexdlc.github.io/codex-core/](https://codexdlc.github.io/codex-core/)**
|
|
99
|
+
|
|
100
|
+
## Part of the Codex ecosystem
|
|
101
|
+
|
|
102
|
+
- **[codex-core](https://github.com/codexdlc/codex-core)**: Foundational utilities and DTOs.
|
|
103
|
+
- **[codex-platform](https://github.com/codexdlc/codex-platform)**: Core platform components and HTTP APIs.
|
|
104
|
+
- **[codex-bot](https://github.com/codexdlc/codex-bot)**: Telegram AI-agent infrastructure.
|
|
105
|
+
- **[codex-services](https://github.com/codexdlc/codex-services)**: Business logic engines (Booking, CRM).
|
|
106
|
+
- **[codex-ai](https://github.com/codexdlc/codex-ai)**: LLM abstraction layer.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!-- Type: LANDING -->
|
|
2
|
+
# codex-core
|
|
3
|
+
|
|
4
|
+
[](https://pypi.org/project/codex-core/)
|
|
5
|
+
[](https://pypi.org/project/codex-core/)
|
|
6
|
+
[](https://github.com/codexdlc/codex-core/blob/main/LICENSE)
|
|
7
|
+
[](https://codexdlc.github.io/codex-core/)
|
|
8
|
+
|
|
9
|
+
Core utilities, immutable DTOs, and environment-driven settings for the Codex WaaS toolkit.
|
|
10
|
+
Provides the foundational building blocks and PII masking used by all other Codex components.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Core only
|
|
18
|
+
pip install codex-core
|
|
19
|
+
|
|
20
|
+
# With Loguru support for advanced structured logging
|
|
21
|
+
pip install "codex-core[loguru]"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from codex_core.core.base_dto import BaseDTO
|
|
28
|
+
|
|
29
|
+
# 1. Define an immutable, PII-aware data transfer object
|
|
30
|
+
class UserDTO(BaseDTO):
|
|
31
|
+
id: int
|
|
32
|
+
email: str # Automatically masked in logs
|
|
33
|
+
phone_number: str # Automatically masked in logs
|
|
34
|
+
|
|
35
|
+
user = UserDTO(id=42, email="user@example.com", phone_number="+491511234567")
|
|
36
|
+
|
|
37
|
+
# 2. Safely log the DTO without leaking personal data
|
|
38
|
+
print(user)
|
|
39
|
+
# Output: UserDTO(id=42, email='***', phone_number='***')
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Modules
|
|
43
|
+
|
|
44
|
+
| Module | Extra | Description |
|
|
45
|
+
| :--- | :--- | :--- |
|
|
46
|
+
| `codex_core.core` | - | Immutable `BaseDTO` and automated `PIIRegistry` for GDPR-safe logging. |
|
|
47
|
+
| `codex_core.common` | `[loguru]` | Phone/name normalization and structured logging adapters (`TaskLogContext`). |
|
|
48
|
+
| `codex_core.settings` | - | Environment-driven configuration via `BaseCommonSettings` (Pydantic Settings). |
|
|
49
|
+
| `codex_core.dev` | `[dev]` | Internal developer tools (`BaseCheckRunner`, `StaticCompiler`, `ProjectTreeGenerator`). |
|
|
50
|
+
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
Full docs with architecture, API reference, and data flow diagrams:
|
|
54
|
+
|
|
55
|
+
**[https://codexdlc.github.io/codex-core/](https://codexdlc.github.io/codex-core/)**
|
|
56
|
+
|
|
57
|
+
## Part of the Codex ecosystem
|
|
58
|
+
|
|
59
|
+
- **[codex-core](https://github.com/codexdlc/codex-core)**: Foundational utilities and DTOs.
|
|
60
|
+
- **[codex-platform](https://github.com/codexdlc/codex-platform)**: Core platform components and HTTP APIs.
|
|
61
|
+
- **[codex-bot](https://github.com/codexdlc/codex-bot)**: Telegram AI-agent infrastructure.
|
|
62
|
+
- **[codex-services](https://github.com/codexdlc/codex-services)**: Business logic engines (Booking, CRM).
|
|
63
|
+
- **[codex-ai](https://github.com/codexdlc/codex-ai)**: LLM abstraction layer.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[🏠 Home](../index.md) | [🧭 Guide (EN)](README.md) | [⚙️ API Reference](
|
|
1
|
+
[🏠 Home](../index.md) | [🧭 Guide (EN)](README.md) | [⚙️ API Reference](api/index.md)
|
|
2
2
|
|
|
3
3
|
# Guide: Overview (EN)
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Welcome to the **codex-core** guide! This library serves as the shared foundatio
|
|
|
6
6
|
|
|
7
7
|
## Documentation Sections
|
|
8
8
|
|
|
9
|
-
### 1. [Getting Started](
|
|
9
|
+
### 1. [Getting Started](tasks/getting_started.md)
|
|
10
10
|
How to install and integrate `codex-core` into your project.
|
|
11
11
|
|
|
12
12
|
### 2. [🛡️ Architecture & Platform](architecture/README.md)
|
|
@@ -19,5 +19,5 @@ Detailed breakdown of the core platform components:
|
|
|
19
19
|
### 3. [🗺 Evolution](../evolution/roadmap.md)
|
|
20
20
|
Our core purpose and development philosophy.
|
|
21
21
|
|
|
22
|
-
### 4. [⚙️ API Reference](
|
|
22
|
+
### 4. [⚙️ API Reference](api/index.md)
|
|
23
23
|
Technical details for developers.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Dev Tools — API Reference
|
|
2
|
+
|
|
3
|
+
## BaseCheckRunner
|
|
4
|
+
|
|
5
|
+
::: codex_core.dev.check_runner.BaseCheckRunner
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## StaticCompiler
|
|
10
|
+
|
|
11
|
+
::: codex_core.dev.static_compiler.compiler.StaticCompiler
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## CSSCompiler
|
|
16
|
+
|
|
17
|
+
::: codex_core.dev.static_compiler.css.CSSCompiler
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## JSCompiler
|
|
22
|
+
|
|
23
|
+
::: codex_core.dev.static_compiler.js.JSCompiler
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## ProjectTreeGenerator
|
|
28
|
+
|
|
29
|
+
::: codex_core.dev.project_tree.ProjectTreeGenerator
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[🏠 Home](
|
|
1
|
+
[🏠 Home](../../index.md) | [🧭 Guide (EN)](../README.md) | [⚙️ API Reference](index.md)
|
|
2
2
|
|
|
3
3
|
# API Reference Overview
|
|
4
4
|
|
|
@@ -9,6 +9,7 @@ Welcome to the **codex-core** API Reference! This section provides detailed info
|
|
|
9
9
|
- **[🛡️ Core (DTO & PII)](core.md)**: Base data models and PII protection utilities.
|
|
10
10
|
- **[🛠️ Common (Utilities)](common.md)**: Phone, text, and logging helpers.
|
|
11
11
|
- **[⚙️ Settings (Config)](settings.md)**: Base configuration patterns.
|
|
12
|
+
- **[🛠️ Dev Tools](dev.md)**: Internal developer tools.
|
|
12
13
|
|
|
13
14
|
## Technical Details
|
|
14
15
|
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
[🏠 Home](../../../index.md) | [🧭 Guide (EN)](../../README.md) | [🛠️ Dev API](../../api/dev.md)
|
|
2
|
+
|
|
3
|
+
# Dev Tools (Architecture)
|
|
4
|
+
|
|
5
|
+
The `dev` module provides reusable development utilities shared across all **Codex** projects.
|
|
6
|
+
All tools are **pure Python** (stdlib only) — no external dependencies required.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. BaseCheckRunner — Quality Gate
|
|
11
|
+
|
|
12
|
+
A base class for project-level quality gate scripts. Every Codex project has a `tools/dev/check.py`
|
|
13
|
+
that inherits from `BaseCheckRunner` and overrides only what differs.
|
|
14
|
+
|
|
15
|
+
### Standardized behavior (base class)
|
|
16
|
+
|
|
17
|
+
| Check | Command |
|
|
18
|
+
|-------|---------|
|
|
19
|
+
| Quality | `pre-commit run --all-files` |
|
|
20
|
+
| Types | `sys.executable -m mypy src/` |
|
|
21
|
+
| Security | `pip-audit --skip-editable` |
|
|
22
|
+
| Unit tests | `pytest -m unit -v --tb=short` |
|
|
23
|
+
| Integration | `pytest -m integration -v --tb=short` |
|
|
24
|
+
|
|
25
|
+
`--skip-editable` ensures pip-audit only scans real PyPI packages,
|
|
26
|
+
not locally installed editable codex-* dependencies.
|
|
27
|
+
|
|
28
|
+
### CLI interface
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python tools/dev/check.py --lint # pre-commit only
|
|
32
|
+
python tools/dev/check.py --types # mypy only
|
|
33
|
+
python tools/dev/check.py --security # pip-audit only
|
|
34
|
+
python tools/dev/check.py --tests unit
|
|
35
|
+
python tools/dev/check.py --tests integration
|
|
36
|
+
python tools/dev/check.py --all # lint + types + security + unit, asks about integration
|
|
37
|
+
python tools/dev/check.py --ci # everything non-interactively (GitHub Actions)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Usage in a project
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
# tools/dev/check.py
|
|
44
|
+
from pathlib import Path
|
|
45
|
+
from codex_core.dev.check_runner import BaseCheckRunner
|
|
46
|
+
|
|
47
|
+
class CheckRunner(BaseCheckRunner):
|
|
48
|
+
PROJECT_NAME = "my-project"
|
|
49
|
+
INTEGRATION_REQUIRES = "Redis"
|
|
50
|
+
|
|
51
|
+
if __name__ == "__main__":
|
|
52
|
+
CheckRunner(Path(__file__).parent.parent.parent).main()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Extending for Docker or migrations
|
|
56
|
+
|
|
57
|
+
Override `extra_checks()` to add project-specific gates:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
class CheckRunner(BaseCheckRunner):
|
|
61
|
+
PROJECT_NAME = "codex-django"
|
|
62
|
+
INTEGRATION_REQUIRES = "PostgreSQL + Redis"
|
|
63
|
+
|
|
64
|
+
def extra_checks(self) -> bool:
|
|
65
|
+
# manage.py check, migrate --check, etc.
|
|
66
|
+
return True
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### CI-specific override (codex-ai pattern)
|
|
70
|
+
|
|
71
|
+
When integration tests require API keys that may be absent, override `run_tests()`
|
|
72
|
+
to add `--no-cov` so the coverage threshold gate does not fail on 0 collected tests:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
def run_tests(self, marker: str = "unit") -> bool:
|
|
76
|
+
if marker == "integration":
|
|
77
|
+
success, _ = self.run_command(
|
|
78
|
+
f'"{sys.executable}" -m pytest {self.tests_dir}'
|
|
79
|
+
f" -m integration -v --tb=short --no-cov"
|
|
80
|
+
)
|
|
81
|
+
return success
|
|
82
|
+
return super().run_tests(marker)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 2. ProjectTreeGenerator
|
|
88
|
+
|
|
89
|
+
Generates a human-readable directory tree of any project and saves it to `project_structure.txt`.
|
|
90
|
+
Useful for documentation, onboarding, and architecture reviews.
|
|
91
|
+
|
|
92
|
+
### Features
|
|
93
|
+
|
|
94
|
+
- Interactive menu — pick a single top-level folder or scan the full project
|
|
95
|
+
- Pre-configured ignore lists (`.venv`, `__pycache__`, `node_modules`, etc.)
|
|
96
|
+
- Extendable: pass custom `ignore_dirs` / `ignore_extensions` sets
|
|
97
|
+
|
|
98
|
+
### Usage in a project
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# tools/dev/generate_project_tree.py
|
|
102
|
+
from pathlib import Path
|
|
103
|
+
from codex_core.dev.project_tree import ProjectTreeGenerator
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
ProjectTreeGenerator(Path(__file__).parent.parent.parent).interactive()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Programmatic usage
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
gen = ProjectTreeGenerator(root=Path("/my/project"))
|
|
113
|
+
|
|
114
|
+
# Full project → project_structure.txt
|
|
115
|
+
gen.generate(target_dir=None, output=Path("project_structure.txt"))
|
|
116
|
+
|
|
117
|
+
# Only the src/ folder
|
|
118
|
+
gen.generate(target_dir="src", output=Path("src_structure.txt"))
|
|
119
|
+
|
|
120
|
+
# Custom ignore list
|
|
121
|
+
gen = ProjectTreeGenerator(
|
|
122
|
+
root=Path("/my/project"),
|
|
123
|
+
ignore_dirs=frozenset({".git", ".venv", "build"}),
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 3. StaticCompiler — CSS & JS Bundler
|
|
130
|
+
|
|
131
|
+
A pure Python static asset compiler. Resolves CSS `@import` chains and concatenates
|
|
132
|
+
JS source files into bundles. No Node.js, no external packages required.
|
|
133
|
+
|
|
134
|
+
### Sub-modules
|
|
135
|
+
|
|
136
|
+
| Module | Responsibility |
|
|
137
|
+
|--------|---------------|
|
|
138
|
+
| `css.py` | Resolve `@import url(...)`, remove comments, minify |
|
|
139
|
+
| `js.py` | Concatenate sources, remove comments, minify |
|
|
140
|
+
| `compiler.py` | Orchestration, config parsing, two modes |
|
|
141
|
+
|
|
142
|
+
### Config format (`compiler_config.json`)
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"css": {
|
|
147
|
+
"base.css": "app.css"
|
|
148
|
+
},
|
|
149
|
+
"js": {
|
|
150
|
+
"app.js": ["vendor/alpine.js", "src/main.js", "src/ui.js"]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Old CSS-only format is supported for backwards compatibility:
|
|
156
|
+
```json
|
|
157
|
+
{ "base.css": "app.css" }
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Mode 1 — Single project
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from pathlib import Path
|
|
164
|
+
from codex_core.dev.static_compiler import StaticCompiler
|
|
165
|
+
|
|
166
|
+
root = Path(__file__).parent.parent.parent
|
|
167
|
+
static = root / "src" / "backend_django" / "static"
|
|
168
|
+
|
|
169
|
+
StaticCompiler().compile_from_config(
|
|
170
|
+
config=static / "css" / "compiler_config.json",
|
|
171
|
+
css_dir=static / "css",
|
|
172
|
+
js_dir=static / "js",
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Mode 2 — Multi-project (landings)
|
|
177
|
+
|
|
178
|
+
Compile multiple sub-projects from a single master settings file:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"projects": [
|
|
183
|
+
{
|
|
184
|
+
"name": "landing-ru",
|
|
185
|
+
"config": "src/landing_ru/static/css/compiler_config.json",
|
|
186
|
+
"css_dir": "src/landing_ru/static/css",
|
|
187
|
+
"js_dir": "src/landing_ru/static/js"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "landing-en",
|
|
191
|
+
"config": "src/landing_en/static/css/compiler_config.json"
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
StaticCompiler().compile_from_settings(Path("static_settings.json"))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Flags
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
StaticCompiler(css=True, js=False) # CSS only
|
|
205
|
+
StaticCompiler(js=True, css=False) # JS only
|
|
206
|
+
StaticCompiler(minify=True) # full minification
|
|
207
|
+
StaticCompiler(remove_comments=False) # keep comments
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Project-level entry point
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
# tools/static/compile.py (project-specific, ~10 lines)
|
|
214
|
+
from pathlib import Path
|
|
215
|
+
from codex_core.dev.static_compiler import StaticCompiler
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
root = Path(__file__).parent.parent.parent
|
|
219
|
+
static = root / "src" / "backend_django" / "static"
|
|
220
|
+
StaticCompiler().compile_from_config(
|
|
221
|
+
config=static / "css" / "compiler_config.json",
|
|
222
|
+
css_dir=static / "css",
|
|
223
|
+
js_dir=static / "js",
|
|
224
|
+
)
|
|
225
|
+
```
|