From f06c13c195e020a4d6352af01f7d4a96e683d9d7 Mon Sep 17 00:00:00 2001 From: StillHammer Date: Thu, 27 Nov 2025 14:20:56 +0800 Subject: [PATCH] fix: Auto-detect modules path (./modules/ or ./build/modules/) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main.cpp now checks for modules in ./modules/ first, falls back to ./build/modules/ if not found or empty - Allows running from project root: ./build/aissia - Update SUCCESSION.md with current state and FileSystem tools docs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- docs/SUCCESSION.md | 247 +++++++++++++++++++++++---------------------- src/main.cpp | 10 +- 2 files changed, 134 insertions(+), 123 deletions(-) diff --git a/docs/SUCCESSION.md b/docs/SUCCESSION.md index f9d8b3a..1b9e9bd 100644 --- a/docs/SUCCESSION.md +++ b/docs/SUCCESSION.md @@ -2,52 +2,45 @@ ## Contexte -AISSIA = Assistant vocal agentique basé sur GroveEngine (C++17 hot-reload). Architecture "Claude Code en vocal" avec tools internes + MCP. +AISSIA = Assistant vocal agentique basé sur GroveEngine (C++17 hot-reload). Architecture "Claude Code en vocal" avec tools internes + FileSystem + MCP. -**Dernier commit** : `92fb0b7` +**Dernier commit** : `37b62b5` -## Ce qui a été fait (Session actuelle) +## État Actuel -### Infrastructure de Tests d'Intégration +### Ce qui fonctionne -Créé **110 tests d'intégration** avec Catch2 : +✅ **Build complet** - `cmake -B build && cmake --build build -j4` +✅ **6 modules hot-reload** - Scheduler, Notification, Monitoring, AI, Voice, Storage +✅ **4 services** - LLMService, StorageService, PlatformService, VoiceService +✅ **17 tools pour l'agent** : + - 11 tools internes (via IIO pub/sub) + - 6 FileSystem tools (read/write/edit/list/glob/grep) + - MCP tools (désactivés par défaut) +✅ **Tests** - 67/75 tests modules+types passent -``` -tests/ -├── CMakeLists.txt # Config Catch2, targets test_all/test_modules/test_mcp -├── main.cpp -├── mocks/ -│ ├── MockIO.hpp/cpp # Mock IIO pub/sub (fonctionnel) -│ └── MockTransport.hpp # Mock IMCPTransport (fonctionnel) -├── utils/ -│ ├── TestHelpers.hpp # Macros REQUIRE_PUBLISHED, tags -│ └── TimeSimulator.hpp # Simulation gameTime pour modules -├── fixtures/ -│ ├── echo_server.py # Echo JSON-RPC pour tests transport -│ ├── mock_mcp_server.py # Serveur MCP complet (initialize, tools/list, tools/call) -│ └── mock_mcp.json # Config test -├── modules/ # 60 TI (10 par module) -│ ├── SchedulerModuleTests.cpp -│ ├── NotificationModuleTests.cpp -│ ├── MonitoringModuleTests.cpp -│ ├── AIModuleTests.cpp -│ ├── VoiceModuleTests.cpp -│ └── StorageModuleTests.cpp -└── mcp/ # 50 TI - ├── MCPTypesTests.cpp # 15 TI - serialisation JSON - ├── StdioTransportTests.cpp # 20 TI - process spawn, IPC, timeout - └── MCPClientTests.cpp # 15 TI - multi-server, routing +### Lancement + +```bash +# Build +cmake -B build && cmake --build build -j4 + +# Run (depuis racine ou build/) +./build/aissia + +# Tests +cmake -B build -DBUILD_TESTING=ON +./build/tests/aissia_tests "[scheduler],[notification]" # Modules +./build/tests/aissia_tests "[types]" # MCP types ``` -### Plan de Tests Détaillé +### Variables d'Environnement -Créé `PLAN_TESTS_INTEGRATION.md` avec : -- Tableau de tous les 110 TI avec descriptions -- Exemples de code pour chaque catégorie -- Ordre d'implémentation en 5 sprints -- Métriques de succès +```bash +export ANTHROPIC_API_KEY="sk-ant-..." # Requis pour Claude API +``` -## Architecture Actuelle +## Architecture ``` ┌─────────────────────────────────────────────────────────────┐ @@ -55,8 +48,9 @@ Créé `PLAN_TESTS_INTEGRATION.md` avec : │ (Agentic Loop) │ ├─────────────────────────────────────────────────────────────┤ │ ToolRegistry │ -│ ├── InternalTools (11 tools) ─────► IIO pub/sub │ -│ └── MCPClient (tools externes) ─────► stdio JSON-RPC │ +│ ├── InternalTools (11) ─────► IIO pub/sub │ +│ ├── FileSystemTools (6) ────► Direct C++ (read/write/edit) │ +│ └── MCPClient (optionnel) ──► stdio JSON-RPC │ └─────────────────────────────────────────────────────────────┘ │ ┌──────────────┬─────┴──────┬──────────────┐ @@ -64,111 +58,122 @@ Créé `PLAN_TESTS_INTEGRATION.md` avec : Module Module Module Module ``` -### Modules (Hot-Reloadable) +### Tools Disponibles -| Module | Fonctionnalité | Topics | -|--------|----------------|--------| -| SchedulerModule | Tâches, hyperfocus, breaks | `scheduler:*` | -| NotificationModule | Queue notifications, priorités | - | -| MonitoringModule | Classification apps, stats | `monitoring:*` | -| AIModule | Logique LLM, suggestions | `ai:*`, `llm:*` | -| VoiceModule | TTS/STT coordination | `voice:*` | -| StorageModule | Notes, persistence | `storage:*` | +| Catégorie | Tools | Communication | +|-----------|-------|---------------| +| Scheduler | get_current_task, list_tasks, start_task, complete_task, start_break | IIO | +| Monitoring | get_focus_stats, get_current_app | IIO | +| Storage | save_note, query_notes, get_session_history | IIO | +| Voice | speak | IIO | +| FileSystem | read_file, write_file, edit_file, list_directory, glob_files, grep_files | Direct C++ | -### Services (Non Hot-Reloadable) +### FileSystem Tools (Nouveau) -| Service | Rôle | -|---------|------| -| LLMService | HTTP Claude/OpenAI, agentic loop, tools | -| StorageService | SQLite, prepared statements | -| PlatformService | Window tracking (Win32/X11) | -| VoiceService | TTS (SAPI/espeak), STT (Whisper) | +Implémentés dans `src/shared/tools/FileSystemTools.*` : + +```cpp +// Lecture avec numéros de ligne +FileSystemTools::execute("read_file", {{"path", "/path/to/file"}, {"limit", 10}}); + +// Édition style Claude Code +FileSystemTools::execute("edit_file", { + {"path", "/path/to/file"}, + {"old_string", "foo"}, + {"new_string", "bar"} +}); + +// Recherche +FileSystemTools::execute("glob_files", {{"pattern", "**/*.cpp"}}); +FileSystemTools::execute("grep_files", {{"pattern", "TODO"}, {"path", "./src"}}); +``` + +**Sécurité** : +- Chemins autorisés configurables +- Patterns bloqués : `*.env`, `*.key`, `*credentials*` +- Limites : 1MB lecture, 10MB écriture + +## Fichiers Clés + +### Nouveaux (Session actuelle) +``` +src/shared/tools/FileSystemTools.hpp +src/shared/tools/FileSystemTools.cpp +PLAN_FILESYSTEM_TOOLS.md +``` + +### Services +``` +src/services/LLMService.* # Agentic loop, tools registry +src/services/StorageService.* # SQLite persistence +src/services/PlatformService.* # Window tracking +src/services/VoiceService.* # TTS/STT +``` + +### Modules (Hot-Reload) +``` +src/modules/SchedulerModule.* +src/modules/NotificationModule.* +src/modules/MonitoringModule.* +src/modules/AIModule.* +src/modules/VoiceModule.* +src/modules/StorageModule.* +``` ### MCP +``` +src/shared/mcp/MCPTypes.hpp +src/shared/mcp/MCPClient.* +src/shared/mcp/StdioTransport.* +config/mcp.json +``` -| Fichier | Description | -|---------|-------------| -| `MCPTypes.hpp` | Structs (Tool, Resource, JsonRpc*) | -| `MCPTransport.hpp` | Interface abstraite | -| `StdioTransport.*` | Fork/exec + JSON-RPC stdio | -| `MCPClient.*` | Multi-serveur, routing tools | - -## Commandes +## Tests ```bash -# Build standard -cmake -B build && cmake --build build -j4 - # Build avec tests cmake -B build -DBUILD_TESTING=ON && cmake --build build -j4 -# Exécuter tous les tests -cmake --build build --target test_all +# Par catégorie +./build/tests/aissia_tests "[scheduler]" # 10 tests +./build/tests/aissia_tests "[notification]" # 10 tests +./build/tests/aissia_tests "[types]" # 15 tests MCP -# Tests par catégorie -./build/aissia_tests "[scheduler]" -./build/aissia_tests "[mcp]" -./build/aissia_tests "[mcp][types]" -./build/aissia_tests "[mcp][transport]" - -# Run AISSIA -./build/aissia +# Tous les modules +./build/tests/aissia_tests "[scheduler],[notification],[monitoring],[ai],[voice],[storage]" ``` -## État des Tests - -Les tests sont des **squelettes fonctionnels** : -- Fixtures et mocks implémentés -- TEST_CASE avec assertions réelles -- Certaines vérifications d'état marquées `// TODO` (nécessitent getState() côté module) - -**Prêt à compiler** mais nécessite : -1. Vérifier que GroveEngine expose `grove::Message` correctement -2. Les modules doivent exposer leur état via `getState()` pour les assertions +**Résultats actuels** : +- Modules : 52/60 (87%) +- MCP Types : 15/15 (100%) +- MCP Transport/Client : Nécessite fix serveurs Python ## Prochaines Étapes ### Priorité Haute -1. **Compiler les tests** - `cmake -B build -DBUILD_TESTING=ON` -2. **Fixer les erreurs de compilation** - Probablement des includes manquants -3. **Compléter les `// TODO`** - Assertions sur getState() des modules +1. **Tester avec API key** - Vérifier la boucle agentique complète +2. **Activer MCP filesystem** - Pour tests end-to-end avec tools externes ### Priorité Moyenne -4. **Ajouter CI** - GitHub Actions ou GitLab CI pour run tests -5. **Couverture de code** - gcov/lcov -6. **Tests end-to-end** - Flux complet inter-modules +3. **Fixer tests MCP Transport** - Les serveurs Python reçoivent EOF +4. **Ajouter plus de tools** - add_task, set_reminder, etc. +5. **Streaming responses** - Feedback temps réel pendant génération ### Priorité Basse -7. **Tests de performance** - Latence IIO, throughput MCP -8. **Fuzzing** - MCPTypes parsing, JsonRpc - -## Fichiers Clés Modifiés - -``` -CMakeLists.txt # Ajout option BUILD_TESTING + add_subdirectory(tests) -PLAN_TESTS_INTEGRATION.md # Plan détaillé des 110 TI (nouveau) -tests/ # Toute la structure (nouveau) -``` - -## Variables d'Environnement - -```bash -export ANTHROPIC_API_KEY="sk-ant-..." # Claude API -export BRAVE_API_KEY="..." # Si MCP brave-search activé -``` +6. **Tests end-to-end** - Flux complet inter-modules +7. **CI/CD** - GitHub Actions +8. **Documentation API** - Doxygen ## Notes Techniques -### MockIO -- Capture tous les `publish()` dans un vector -- Permet `injectMessage()` pour simuler messages entrants -- Helpers : `wasPublished()`, `getLastPublished()`, `countPublished()` +### WSL +- Window tracker non disponible (stub utilisé) +- espeak non installé (TTS stub) +- Tout le reste fonctionne -### TimeSimulator -- Simule `gameTime` pour les modules -- `advanceMinutes()` pratique pour tests hyperfocus -- `createInput()` génère le JSON attendu par `process()` - -### Fixtures Python -- `echo_server.py` : echo params en result -- `mock_mcp_server.py` : implémente initialize, tools/list, tools/call +### Hot-Reload +Les modules sont des `.so` chargés dynamiquement. Pour recompiler un module : +```bash +cmake --build build --target SchedulerModule +# Le module sera rechargé au prochain cycle si modifié +``` diff --git a/src/main.cpp b/src/main.cpp index 0a2f065..c254367 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -172,8 +172,14 @@ int main(int argc, char* argv[]) { std::signal(SIGINT, signalHandler); std::signal(SIGTERM, signalHandler); - // Paths - const std::string modulesDir = "./modules/"; + // Paths - try ./modules/ first, fallback to ./build/modules/ + std::string modulesDir = "./modules/"; + if (!fs::exists(modulesDir) || fs::is_empty(modulesDir)) { + if (fs::exists("./build/modules/")) { + modulesDir = "./build/modules/"; + spdlog::info("Using modules from: {}", modulesDir); + } + } const std::string configDir = "./config/"; // =========================================================================