Update all project documentation

This commit is contained in:
2026-04-16 15:20:19 +03:00
parent e752f88ae2
commit 22b85455e1
7 changed files with 94 additions and 38 deletions

View File

@@ -13,32 +13,51 @@ python -m app.komAI
## Architecture
- `app/` - application entry point (komAI.py expected)
- `src/` - source code, `src/__init__.py` exposes centralized API
- `src/` - source code
- `src/utils/` - utilities (config_manager, log_manager)
- `config/` - YAML configuration; `config/global.yaml` is the main config
- `modules/` - pluggable modules, configured via `global.modules`
- `modules/` - pluggable modules
- `tests/` - standalone unit tests
- `log/` - runtime logs
- `tests/` - standalone unit tests (executable from CLI)
## Config System
Modules register parameters at initialization via `config.register()`.
Access global config:
Access via:
```python
import src.utils.config_manager
config = src.utils.config_manager.config
import src.utils.config_manager as config
config = config.config
```
Save config: `config.save()`
Key APIs:
- `config.register(name, val, default, desc, cat, env, validator)`
- `config.get(name, cat)` / `config.getraw(key)`
- `config.set(name, value, cat)` / `config.setraw(key, value)`
- `config.getall(name, cat)` / `config.getrawall(cat)`
- `config.load()` / `config.save()` / `config.reset()`
Constants: `ROOT_KEY = "$root$"`, `DEFAULT_CATEGORY = "global"`
## Logging
All console output is duplicated to log files. Configure in `config/global.yaml`.
Access via:
```python
import src.utils.log_manager as log
```
Key APIs:
- `log.register_global_params()` - register global logging params
- `log.register(module, log_console, log_stderr, log_file, log_level)` - register module
- `log.setup()` - initialize logging
- `log.get_logger(module)` - get logger instance
- `logger.print(msg, level)` - print to console (use instead of print())
**Rule: Never use `print()` - always use `logger.print()`**
Constants: `LOG_CATEGORY`, `LOG_CONSOLE`, `LOG_STDERR`, `LOG_FILE`, `LOG_LEVEL`, etc.
## Env Vars (see `.env.example`)
- `KOMAI_CONFIG` - path to config file (optional)
- `LOGGING_LOG_PATH`, `LOGGING_LOG_FILE`, `LOGGING_LEVEL`
- `KOMAI_CONFIG_FILE` - path to config file (optional)
## Requirements
@@ -47,7 +66,26 @@ All console output is duplicated to log files. Configure in `config/global.yaml`
## Module Development
When creating new modules:
- Register parameters with `config.register(name=..., val=..., cat="module_name", ...)`
- Use categories to organize params
- All param changes trigger validators if set
- Use `getall()` / `getrawall()` for nested param groups
1. Register parameters:
```python
import src.utils.config_manager as config
config.register(name="param", val="value", cat="module_name", ...)
```
2. Use logging:
```python
import src.utils.log_manager as log
log.register(module="module_name", log_console=True, ...)
logger = log.get_logger("module_name")
logger.print("message") # never print()
```
3. Never use `print()` directly - use `logger.print()` instead
## Testing
```bash
python -m tests.test_config_manager
python -m tests.test_log_manager
```