Metadata-Version: 2.4
Name: ai-mini-box-core
Version: 5.0.1
Summary: AI mini box core — system core for small business automation
Project-URL: Homepage, https://github.com/Kibertum/ai-mini-box
Project-URL: Repository, https://github.com/Kibertum/ai-mini-box
Project-URL: Documentation, https://github.com/Kibertum/ai-mini-box
License: MIT License
        
        Copyright (c) 2026 Kibertum
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business
Requires-Python: >=3.12
Requires-Dist: alembic>=1.13
Requires-Dist: cryptography>=42
Requires-Dist: loguru>=0.7
Requires-Dist: pydantic>=2.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest-xdist>=3; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# AI mini box

[![CI](https://github.com/Kibertum/ai-mini-box/actions/workflows/tests.yml/badge.svg)](https://github.com/Kibertum/ai-mini-box/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/ai-mini-box-core)](https://pypi.org/project/ai-mini-box-core/)
[![Python](https://img.shields.io/pypi/pyversions/ai-mini-box-core)](https://pypi.org/project/ai-mini-box-core/)
[![License](https://img.shields.io/github/license/Kibertum/ai-mini-box)](LICENSE)

Системное ядро для автоматизации малого бизнеса. Управление контактами, продуктами, заказами, сообщениями через единый CLI и плагинную систему сервисов.

## Установка

```bash
pip install ai-mini-box-core
```

Для разработки — с тестовыми зависимостями:

```bash
git clone https://github.com/Kibertum/ai-mini-box
cd ai-mini-box
pip install -e packages/core[dev]
pip install -e packages/demo[dev]    # пример сервиса
```

## Быстрый старт

```bash
# Инициализация проекта
ai-mini-box init

# Проверка БД
ai-mini-box check-db

# Настройка
ai-mini-box config show
ai-mini-box config set telegram_bot_token "your_token"
ai-mini-box config set poll_interval 15
ai-mini-box config unset poll_interval
```

## Команды CLI

| Команда | Описание |
|---------|----------|
| `init` | Создать config.json, БД, директории data/ |
| `check-db` | Проверить подключение к БД и схему |
| `config show` | Показать конфигурацию (с группировкой по секциям) |
| `config set <key> <value>` | Установить значение (чувствительные поля шифруются) |
| `config unset <key>` | Сбросить на значение по умолчанию |

Плагины (сервисы) регистрируют свои команды через entry points:

| Команда (из demo) | Описание |
|---|---|
| `demo-list` | Список контактов |
| `demo-get <id>` | Контакт по ID |
| `demo-add <name> <phone>` | Добавить контакт |

Опции: `--verbose`, `--help` доступны для всех команд.

## Архитектура

```
ai_mini_box/
├── core/                  # Слой домена
│   ├── models.py          # Pydantic-модели (Contact, Product, Message, Order)
│   ├── repositories.py    # ABC репозиториев + QueryBuilder
│   ├── container.py       # RepoContainer + AppContext (DI)
│   └── exceptions.py      # Кастомные исключения
├── infrastructure/        # Слой инфраструктуры
│   ├── database.py        # SQLAlchemy engine, session, get_db()
│   ├── config.py          # JsonConfigManager с шифрованием
│   ├── logger.py          # Loguru-логгер
│   ├── orm_models.py      # SQLAlchemy ORM-модели
│   ├── mapping.py         # Мапперы Pydantic ↔ ORM
│   └── repositories/      # SQLAlchemy-реализации репозиториев
└── cli.py                 # Typer CLI + плагинная загрузка
```

**Слои:** `core/` (Pydantic + ABC) → `infrastructure/` (SQLAlchemy + файлы) → `tools/` (CLI-сервисы через entry points).

## Разработка сервиса

См. [docs/developer-guide.md](docs/developer-guide.md).

## Сервисы (инструменты)

Проект включает 30 спецификаций сервисов в `tool-*.md` — от телеграм-бота и email до CRM-синхронизации и юристов. Каждый сервис — отдельный Python-пакет, подключаемый через entry point `ai_mini_box.tools`.

## Тестирование

```bash
pytest packages/core/tests/ packages/demo/tests/ -v
```

Текущий статус: **72 теста, все зелёные** (63 core + 9 demo).

## Лицензия

MIT
