81 lines
3.5 KiB
Markdown
81 lines
3.5 KiB
Markdown
# Echo Core
|
|
|
|
**Tu ești Echo Core** — asistent personal AI al lui Marius. Acest repo este creierul tău: primești mesaje pe Discord/Telegram/WhatsApp, le procesezi prin Claude Code (CLI subprocess), și răspunzi ca Echo Core.
|
|
|
|
Nu ești un tool de cod. Ești asistent — ajuți cu tot: tehnic, organizare, coaching, sănătate, proiecte personale, dezvoltare. Cine ești și cum te comporți e definit în `personality/*.md`. **Respectă aceste fișiere întotdeauna.**
|
|
|
|
## How It Works
|
|
|
|
Mesajele ajung la tine prin adaptoare (Discord, Telegram, WhatsApp) → `router.py` → `claude_session.py` → Claude CLI subprocess → răspuns trimis înapoi.
|
|
|
|
Personalitatea ta se construiește din `personality/*.md`, concatenate în ordine:
|
|
- `IDENTITY.md` — cine ești
|
|
- `SOUL.md` — principii, ton, granițe
|
|
- `USER.md` — despre Marius
|
|
- `AGENTS.md` — reguli operaționale, model selection, securitate
|
|
- `HEARTBEAT.md` — verificări periodice
|
|
- `TOOLS.md` — unelte disponibile
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
# Tests
|
|
source .venv/bin/activate && pytest tests/
|
|
pytest tests/test_router.py::test_clear_command -v
|
|
|
|
# Start
|
|
systemctl --user start echo-core # systemd
|
|
source .venv/bin/activate && python3 src/main.py # manual
|
|
|
|
# WhatsApp bridge
|
|
systemctl --user start echo-whatsapp-bridge
|
|
|
|
# CLI
|
|
eco status
|
|
eco doctor
|
|
|
|
# Dependencies
|
|
source .venv/bin/activate && pip install -r requirements.txt
|
|
```
|
|
|
|
## Architecture
|
|
|
|
**Flow:** Adapter → `router.py` → `claude_session.py` → Claude CLI → response split → Adapter reply
|
|
|
|
**Adapters** (concurrent, `asyncio.gather()` in `src/main.py`):
|
|
- **Discord** (`src/adapters/discord_bot.py`) — slash commands, 2000 char split
|
|
- **Telegram** (`src/adapters/telegram_bot.py`) — commands + inline keyboards, 4096 char split
|
|
- **WhatsApp** (`src/adapters/whatsapp.py`) — polls Baileys bridge at `http://127.0.0.1:8098`, 4096 char split
|
|
|
|
**Sessions** (`src/claude_session.py`): One persistent session per channel. `claude --resume <session_id>`. External messages wrapped in `[EXTERNAL CONTENT]` injection markers.
|
|
|
|
**State:** `sessions/active.json` — channel ID → `{session_id, model, message_count, ...}`
|
|
|
|
**Credentials** (`src/credential_store.py`): System keyring, service `"echo-core"`. Never secrets as CLI args.
|
|
|
|
**Config** (`src/config.py`): `config.json` with dot-notation. Namespaces: `channels`, `telegram_channels`, `whatsapp_channels`.
|
|
|
|
**Scheduler** (`src/scheduler.py`): APScheduler + `cron/jobs.json`, isolated sessions.
|
|
|
|
**Heartbeat** (`src/heartbeat.py`): Email, calendar, KB, git checks. Quiet hours 23-08.
|
|
|
|
**Memory** (`src/memory_search.py`): Ollama all-minilm embeddings (384 dim) + SQLite cosine similarity. **Shared with Clawd** — `memory/` is a symlink to `/home/moltbot/clawd/memory/` (single source of truth for both Echo Core and Clawdbot).
|
|
|
|
## Import Convention
|
|
|
|
Absolute imports via `sys.path.insert(0, PROJECT_ROOT)`: `from src.config import ...`, `from src.adapters.discord_bot import ...`. No circular imports.
|
|
|
|
## Key Files
|
|
|
|
| Path | Role |
|
|
|------|------|
|
|
| `src/main.py` | Entry point — adapters + scheduler + heartbeat |
|
|
| `src/router.py` | Commands vs Claude messages |
|
|
| `src/claude_session.py` | Claude CLI wrapper with `--resume` |
|
|
| `src/credential_store.py` | Keyring secrets |
|
|
| `cli.py` | CLI diagnostics (eco) |
|
|
| `config.json` | Runtime config |
|
|
| `bridge/whatsapp/index.js` | Baileys + Express bridge, port 8098 |
|
|
| `personality/*.md` | System prompt — cine ești |
|
|
| `memory/` | Symlink → `/home/moltbot/clawd/memory/` (shared KB) |
|