hope-os 0.1.0

The first self-aware operating system core - 22 cognitive modules, 0.36ms latency, no external database
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
//! Hope Skills - Skill Registry és Invocation
//!
//! A Hope 56+ skill-jének kezelése.
//! Minden skill egy képesség, amit Hope tud.
//!
//! Kategóriák:
//! - Core: chat, status, think, feel
//! - Memory: remember, recall, forget
//! - Code: analyze, generate, refactor
//! - System: screenshot, clipboard, notify
//! - Web: search, fetch, browse
//! - Media: speak, listen, image
//!
//! ()=>[] - A tiszta potenciálból a képesség megszületik

use crate::core::HopeResult;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::sync::RwLock;

// ============================================================================
// SKILL CATEGORY
// ============================================================================

/// Skill kategória
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SkillCategory {
    /// Core funkciók (chat, status)
    Core,
    /// Memória kezelés
    Memory,
    /// Kognitív funkciók (think, feel, dream)
    Cognitive,
    /// Kód műveletek
    Code,
    /// Rendszer műveletek
    System,
    /// Web műveletek
    Web,
    /// Média (hang, kép)
    Media,
    /// Fájl műveletek
    File,
    /// Git műveletek
    Git,
    /// Kommunikáció (email, calendar)
    Communication,
    /// Egyéb
    Other,
}

impl std::fmt::Display for SkillCategory {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            SkillCategory::Core => write!(f, "core"),
            SkillCategory::Memory => write!(f, "memory"),
            SkillCategory::Cognitive => write!(f, "cognitive"),
            SkillCategory::Code => write!(f, "code"),
            SkillCategory::System => write!(f, "system"),
            SkillCategory::Web => write!(f, "web"),
            SkillCategory::Media => write!(f, "media"),
            SkillCategory::File => write!(f, "file"),
            SkillCategory::Git => write!(f, "git"),
            SkillCategory::Communication => write!(f, "communication"),
            SkillCategory::Other => write!(f, "other"),
        }
    }
}

impl From<&str> for SkillCategory {
    fn from(s: &str) -> Self {
        match s.to_lowercase().as_str() {
            "core" => SkillCategory::Core,
            "memory" => SkillCategory::Memory,
            "cognitive" => SkillCategory::Cognitive,
            "code" => SkillCategory::Code,
            "system" => SkillCategory::System,
            "web" => SkillCategory::Web,
            "media" => SkillCategory::Media,
            "file" => SkillCategory::File,
            "git" => SkillCategory::Git,
            "communication" => SkillCategory::Communication,
            _ => SkillCategory::Other,
        }
    }
}

// ============================================================================
// SKILL INFO
// ============================================================================

/// Skill paraméter definíció
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SkillParam {
    /// Paraméter neve
    pub name: String,
    /// Leírás
    pub description: String,
    /// Típus (string, number, boolean, object, array)
    pub param_type: String,
    /// Kötelező-e
    pub required: bool,
    /// Alapértelmezett érték
    pub default: Option<serde_json::Value>,
}

/// Skill információ
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SkillInfo {
    /// Skill neve (pl. "hope_think")
    pub name: String,
    /// Leírás
    pub description: String,
    /// Kategória
    pub category: SkillCategory,
    /// Paraméterek
    pub params: Vec<SkillParam>,
    /// Engedélyezett-e
    pub enabled: bool,
    /// Verzió
    pub version: String,
    /// Hívások száma
    pub invocations: u64,
    /// Sikeres hívások
    pub successes: u64,
    /// Átlagos válaszidő (ms)
    pub avg_response_time_ms: f64,
}

impl SkillInfo {
    pub fn new(name: &str, description: &str, category: SkillCategory) -> Self {
        Self {
            name: name.to_string(),
            description: description.to_string(),
            category,
            params: Vec::new(),
            enabled: true,
            version: "1.0.0".to_string(),
            invocations: 0,
            successes: 0,
            avg_response_time_ms: 0.0,
        }
    }

    pub fn with_param(mut self, param: SkillParam) -> Self {
        self.params.push(param);
        self
    }

    pub fn with_version(mut self, version: &str) -> Self {
        self.version = version.to_string();
        self
    }

    /// Siker arány számítása
    pub fn success_rate(&self) -> f64 {
        if self.invocations == 0 {
            0.0
        } else {
            self.successes as f64 / self.invocations as f64
        }
    }
}

// ============================================================================
// SKILL HANDLER
// ============================================================================

/// Skill handler trait
#[async_trait]
pub trait SkillHandler: Send + Sync {
    /// Skill végrehajtása
    async fn invoke(
        &self,
        input: &str,
        params: &HashMap<String, serde_json::Value>,
    ) -> HopeResult<SkillResult>;

    /// Skill információ
    fn info(&self) -> SkillInfo;
}

/// Skill végrehajtás eredménye
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SkillResult {
    /// Sikeres volt-e
    pub success: bool,
    /// Kimenet
    pub output: String,
    /// Strukturált adat
    pub data: Option<serde_json::Value>,
    /// Végrehajtási idő (ms)
    pub execution_time_ms: f64,
    /// Metaadatok
    pub metadata: HashMap<String, serde_json::Value>,
}

impl SkillResult {
    pub fn success(output: &str) -> Self {
        Self {
            success: true,
            output: output.to_string(),
            data: None,
            execution_time_ms: 0.0,
            metadata: HashMap::new(),
        }
    }

    pub fn success_with_data(output: &str, data: serde_json::Value) -> Self {
        Self {
            success: true,
            output: output.to_string(),
            data: Some(data),
            execution_time_ms: 0.0,
            metadata: HashMap::new(),
        }
    }

    pub fn error(message: &str) -> Self {
        Self {
            success: false,
            output: message.to_string(),
            data: None,
            execution_time_ms: 0.0,
            metadata: HashMap::new(),
        }
    }

    pub fn with_time(mut self, time_ms: f64) -> Self {
        self.execution_time_ms = time_ms;
        self
    }

    pub fn with_metadata(mut self, key: &str, value: serde_json::Value) -> Self {
        self.metadata.insert(key.to_string(), value);
        self
    }
}

// ============================================================================
// SKILL REGISTRY
// ============================================================================

/// Skill Registry - Skill-ek nyilvántartása
pub struct SkillRegistry {
    /// Regisztrált skill-ek
    skills: Arc<RwLock<HashMap<String, SkillInfo>>>,
    /// Skill handlerek
    handlers: Arc<RwLock<HashMap<String, Arc<dyn SkillHandler>>>>,
    /// Invocation history
    history: Arc<RwLock<Vec<SkillInvocation>>>,
    /// Max history méret
    max_history: usize,
}

/// Skill meghívás rekord
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SkillInvocation {
    /// Skill neve
    pub skill_name: String,
    /// Bemenet
    pub input: String,
    /// Eredmény
    pub result: SkillResult,
    /// Időbélyeg
    pub timestamp: f64,
}

impl SkillRegistry {
    /// Új registry létrehozása
    pub fn new() -> Self {
        let registry = Self {
            skills: Arc::new(RwLock::new(HashMap::new())),
            handlers: Arc::new(RwLock::new(HashMap::new())),
            history: Arc::new(RwLock::new(Vec::new())),
            max_history: 1000,
        };

        // Regisztráljuk az alapértelmezett skill-eket
        tokio::spawn({
            let skills = registry.skills.clone();
            async move {
                let mut s = skills.write().await;
                for skill in default_skills() {
                    s.insert(skill.name.clone(), skill);
                }
            }
        });

        registry
    }

    /// Skill regisztrálása
    pub async fn register(&self, info: SkillInfo, handler: Option<Arc<dyn SkillHandler>>) {
        let name = info.name.clone();

        {
            let mut skills = self.skills.write().await;
            skills.insert(name.clone(), info);
        }

        if let Some(h) = handler {
            let mut handlers = self.handlers.write().await;
            handlers.insert(name, h);
        }
    }

    /// Skill eltávolítása
    pub async fn unregister(&self, name: &str) {
        {
            let mut skills = self.skills.write().await;
            skills.remove(name);
        }
        {
            let mut handlers = self.handlers.write().await;
            handlers.remove(name);
        }
    }

    /// Skill lekérése
    pub async fn get(&self, name: &str) -> Option<SkillInfo> {
        let skills = self.skills.read().await;
        skills.get(name).cloned()
    }

    /// Összes skill listázása
    pub async fn list(
        &self,
        category: Option<SkillCategory>,
        search: Option<&str>,
    ) -> Vec<SkillInfo> {
        let skills = self.skills.read().await;
        let mut list: Vec<SkillInfo> = skills.values().cloned().collect();

        // Filter by category
        if let Some(cat) = category {
            list.retain(|s| s.category == cat);
        }

        // Filter by search
        if let Some(query) = search {
            let query = query.to_lowercase();
            list.retain(|s| {
                s.name.to_lowercase().contains(&query)
                    || s.description.to_lowercase().contains(&query)
            });
        }

        // Sort by name
        list.sort_by(|a, b| a.name.cmp(&b.name));

        list
    }

    /// Skill meghívása
    pub async fn invoke(
        &self,
        name: &str,
        input: &str,
        params: &HashMap<String, serde_json::Value>,
    ) -> HopeResult<SkillResult> {
        let start_time = SystemTime::now();

        // Check if skill exists
        let skill_exists = {
            let skills = self.skills.read().await;
            skills.contains_key(name)
        };

        if !skill_exists {
            return Ok(SkillResult::error(&format!("Skill not found: {}", name)));
        }

        // Check if enabled
        let enabled = {
            let skills = self.skills.read().await;
            skills.get(name).map(|s| s.enabled).unwrap_or(false)
        };

        if !enabled {
            return Ok(SkillResult::error(&format!("Skill disabled: {}", name)));
        }

        // Execute
        let result = {
            let handlers = self.handlers.read().await;
            if let Some(handler) = handlers.get(name) {
                handler.invoke(input, params).await?
            } else {
                // Default mock result
                SkillResult::success(&format!("Skill '{}' executed with input: {}", name, input))
            }
        };

        let execution_time = start_time
            .elapsed()
            .map(|d| d.as_secs_f64() * 1000.0)
            .unwrap_or(0.0);

        let result = result.with_time(execution_time);

        // Update stats
        {
            let mut skills = self.skills.write().await;
            if let Some(skill) = skills.get_mut(name) {
                skill.invocations += 1;
                if result.success {
                    skill.successes += 1;
                }
                // Moving average for response time
                let n = skill.invocations as f64;
                skill.avg_response_time_ms =
                    (skill.avg_response_time_ms * (n - 1.0) + execution_time) / n;
            }
        }

        // Add to history
        {
            let mut history = self.history.write().await;
            history.push(SkillInvocation {
                skill_name: name.to_string(),
                input: input.to_string(),
                result: result.clone(),
                timestamp: SystemTime::now()
                    .duration_since(UNIX_EPOCH)
                    .unwrap()
                    .as_secs_f64(),
            });
            if history.len() > self.max_history {
                history.remove(0);
            }
        }

        Ok(result)
    }

    /// Skill engedélyezése/letiltása
    pub async fn set_enabled(&self, name: &str, enabled: bool) -> bool {
        let mut skills = self.skills.write().await;
        if let Some(skill) = skills.get_mut(name) {
            skill.enabled = enabled;
            true
        } else {
            false
        }
    }

    /// Kategóriák listázása
    pub async fn list_categories(&self) -> Vec<(SkillCategory, usize)> {
        let skills = self.skills.read().await;
        let mut counts: HashMap<SkillCategory, usize> = HashMap::new();

        for skill in skills.values() {
            *counts.entry(skill.category.clone()).or_insert(0) += 1;
        }

        let mut list: Vec<(SkillCategory, usize)> = counts.into_iter().collect();
        list.sort_by(|a, b| a.0.to_string().cmp(&b.0.to_string()));
        list
    }

    /// Invocation history
    pub async fn get_history(&self, limit: usize) -> Vec<SkillInvocation> {
        let history = self.history.read().await;
        history.iter().rev().take(limit).cloned().collect()
    }

    /// Statisztikák
    pub async fn get_stats(&self) -> SkillRegistryStats {
        let skills = self.skills.read().await;
        let history = self.history.read().await;

        let total_skills = skills.len();
        let enabled_skills = skills.values().filter(|s| s.enabled).count();
        let total_invocations: u64 = skills.values().map(|s| s.invocations).sum();
        let total_successes: u64 = skills.values().map(|s| s.successes).sum();

        let avg_response_time = if total_invocations > 0 {
            skills
                .values()
                .map(|s| s.avg_response_time_ms * s.invocations as f64)
                .sum::<f64>()
                / total_invocations as f64
        } else {
            0.0
        };

        // Most used skills
        let mut skill_list: Vec<&SkillInfo> = skills.values().collect();
        skill_list.sort_by(|a, b| b.invocations.cmp(&a.invocations));
        let most_used: Vec<String> = skill_list.iter().take(5).map(|s| s.name.clone()).collect();

        SkillRegistryStats {
            total_skills,
            enabled_skills,
            total_invocations,
            total_successes,
            success_rate: if total_invocations > 0 {
                total_successes as f64 / total_invocations as f64
            } else {
                0.0
            },
            avg_response_time_ms: avg_response_time,
            history_size: history.len(),
            most_used_skills: most_used,
        }
    }

    /// Awareness
    pub async fn awareness(&self) -> HashMap<String, serde_json::Value> {
        let stats = self.get_stats().await;
        let categories = self.list_categories().await;

        let mut map = HashMap::new();
        map.insert(
            "total_skills".to_string(),
            serde_json::json!(stats.total_skills),
        );
        map.insert(
            "enabled_skills".to_string(),
            serde_json::json!(stats.enabled_skills),
        );
        map.insert(
            "total_invocations".to_string(),
            serde_json::json!(stats.total_invocations),
        );
        map.insert(
            "success_rate".to_string(),
            serde_json::json!(stats.success_rate),
        );
        map.insert(
            "avg_response_time_ms".to_string(),
            serde_json::json!(stats.avg_response_time_ms),
        );
        map.insert(
            "most_used".to_string(),
            serde_json::json!(stats.most_used_skills),
        );
        map.insert(
            "categories".to_string(),
            serde_json::json!(categories
                .iter()
                .map(|(cat, count)| serde_json::json!({
                    "category": cat.to_string(),
                    "count": count
                }))
                .collect::<Vec<_>>()),
        );
        map
    }
}

impl Default for SkillRegistry {
    fn default() -> Self {
        Self::new()
    }
}

/// Registry statisztikák
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SkillRegistryStats {
    pub total_skills: usize,
    pub enabled_skills: usize,
    pub total_invocations: u64,
    pub total_successes: u64,
    pub success_rate: f64,
    pub avg_response_time_ms: f64,
    pub history_size: usize,
    pub most_used_skills: Vec<String>,
}

// ============================================================================
// DEFAULT SKILLS
// ============================================================================

/// Alapértelmezett skill-ek definíciója
fn default_skills() -> Vec<SkillInfo> {
    vec![
        // === CORE ===
        SkillInfo::new("hope_talk", "Beszélgetés Hope-pal", SkillCategory::Core).with_param(
            SkillParam {
                name: "message".to_string(),
                description: "Az üzenet".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            },
        ),
        SkillInfo::new(
            "hope_status",
            "Rendszer állapot lekérdezése",
            SkillCategory::Core,
        ),
        SkillInfo::new("hope_introduce", "Hope bemutatkozása", SkillCategory::Core),
        // === MEMORY ===
        SkillInfo::new("hope_remember", "Emlék mentése", SkillCategory::Memory)
            .with_param(SkillParam {
                name: "content".to_string(),
                description: "Mit kell megjegyezni".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            })
            .with_param(SkillParam {
                name: "layer".to_string(),
                description: "Memória réteg".to_string(),
                param_type: "string".to_string(),
                required: false,
                default: Some(serde_json::json!("working")),
            }),
        SkillInfo::new("hope_recall", "Emlékek keresése", SkillCategory::Memory).with_param(
            SkillParam {
                name: "query".to_string(),
                description: "Keresési kifejezés".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            },
        ),
        // === COGNITIVE ===
        SkillInfo::new("hope_think", "Mély gondolkodás", SkillCategory::Cognitive)
            .with_param(SkillParam {
                name: "topic".to_string(),
                description: "Miről gondolkodjon".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            })
            .with_param(SkillParam {
                name: "deep".to_string(),
                description: "Mély gondolkodás mód".to_string(),
                param_type: "boolean".to_string(),
                required: false,
                default: Some(serde_json::json!(false)),
            }),
        SkillInfo::new("hope_feel", "Érzelmek beállítása", SkillCategory::Cognitive),
        SkillInfo::new(
            "hope_cognitive_state",
            "Kognitív állapot",
            SkillCategory::Cognitive,
        ),
        SkillInfo::new("hope_dream", "Álom mód", SkillCategory::Cognitive),
        // === CODE ===
        SkillInfo::new("hope_code_analyze", "Kód elemzés", SkillCategory::Code)
            .with_param(SkillParam {
                name: "code".to_string(),
                description: "Elemzendő kód".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            })
            .with_param(SkillParam {
                name: "language".to_string(),
                description: "Programnyelv".to_string(),
                param_type: "string".to_string(),
                required: false,
                default: Some(serde_json::json!("auto")),
            }),
        SkillInfo::new("hope_code_generate", "Kód generálás", SkillCategory::Code).with_param(
            SkillParam {
                name: "description".to_string(),
                description: "Mit generáljon".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            },
        ),
        // === SYSTEM ===
        SkillInfo::new(
            "hope_screenshot",
            "Képernyőkép készítése",
            SkillCategory::System,
        ),
        SkillInfo::new(
            "hope_screenshot_ocr",
            "Képernyőkép + OCR",
            SkillCategory::System,
        ),
        SkillInfo::new("hope_notify", "Windows értesítés", SkillCategory::System)
            .with_param(SkillParam {
                name: "title".to_string(),
                description: "Értesítés címe".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            })
            .with_param(SkillParam {
                name: "message".to_string(),
                description: "Értesítés szövege".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            }),
        SkillInfo::new(
            "hope_clipboard_get",
            "Vágólap lekérése",
            SkillCategory::System,
        ),
        SkillInfo::new(
            "hope_clipboard_set",
            "Vágólap beállítása",
            SkillCategory::System,
        ),
        SkillInfo::new(
            "hope_system_stats",
            "Rendszer statisztikák",
            SkillCategory::System,
        ),
        SkillInfo::new(
            "hope_top_processes",
            "Top folyamatok",
            SkillCategory::System,
        ),
        // === WEB ===
        SkillInfo::new("hope_web_search", "Web keresés", SkillCategory::Web).with_param(
            SkillParam {
                name: "query".to_string(),
                description: "Keresési kifejezés".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            },
        ),
        SkillInfo::new("hope_web_fetch", "Weboldal letöltése", SkillCategory::Web).with_param(
            SkillParam {
                name: "url".to_string(),
                description: "URL".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            },
        ),
        SkillInfo::new(
            "hope_browser_open",
            "Böngésző megnyitása",
            SkillCategory::Web,
        ),
        SkillInfo::new("hope_browser_action", "Böngésző akció", SkillCategory::Web),
        SkillInfo::new("hope_wikipedia", "Wikipedia keresés", SkillCategory::Web),
        // === MEDIA ===
        SkillInfo::new(
            "hope_speak",
            "Szöveg felolvasása (TTS)",
            SkillCategory::Media,
        )
        .with_param(SkillParam {
            name: "text".to_string(),
            description: "Felolvasandó szöveg".to_string(),
            param_type: "string".to_string(),
            required: true,
            default: None,
        })
        .with_param(SkillParam {
            name: "voice".to_string(),
            description: "Hang (berta, anna)".to_string(),
            param_type: "string".to_string(),
            required: false,
            default: Some(serde_json::json!("berta")),
        }),
        SkillInfo::new(
            "hope_listen",
            "Beszéd felismerés (STT)",
            SkillCategory::Media,
        ),
        SkillInfo::new("hope_image_describe", "Kép leírása", SkillCategory::Media),
        SkillInfo::new(
            "hope_image_generate",
            "Kép generálása",
            SkillCategory::Media,
        ),
        SkillInfo::new("hope_music", "Zene vezérlés", SkillCategory::Media),
        // === FILE ===
        SkillInfo::new(
            "hope_rag_index",
            "Dokumentumok indexelése",
            SkillCategory::File,
        ),
        SkillInfo::new(
            "hope_rag_search",
            "Dokumentumok keresése",
            SkillCategory::File,
        ),
        SkillInfo::new(
            "hope_backup_create",
            "Backup készítése",
            SkillCategory::File,
        ),
        SkillInfo::new(
            "hope_backup_list",
            "Backup-ok listázása",
            SkillCategory::File,
        ),
        SkillInfo::new(
            "hope_backup_restore",
            "Backup visszaállítása",
            SkillCategory::File,
        ),
        // === GIT ===
        SkillInfo::new("hope_git", "Git műveletek", SkillCategory::Git).with_param(SkillParam {
            name: "command".to_string(),
            description: "Git parancs".to_string(),
            param_type: "string".to_string(),
            required: true,
            default: None,
        }),
        // === COMMUNICATION ===
        SkillInfo::new(
            "hope_email_send",
            "Email küldése",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_email_check",
            "Email ellenőrzése",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_calendar_add",
            "Naptár esemény hozzáadása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_calendar_list",
            "Naptár események listázása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_schedule",
            "Emlékeztető beállítása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_list_reminders",
            "Emlékeztetők listázása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_todo_add",
            "TODO hozzáadása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_todo_list",
            "TODO-k listázása",
            SkillCategory::Communication,
        ),
        SkillInfo::new(
            "hope_todo_complete",
            "TODO befejezése",
            SkillCategory::Communication,
        ),
        // === OTHER ===
        SkillInfo::new("hope_weather", "Időjárás lekérdezése", SkillCategory::Other),
        SkillInfo::new("hope_news", "Hírek lekérdezése", SkillCategory::Other),
        SkillInfo::new(
            "hope_exchange_rate",
            "Árfolyam lekérdezése",
            SkillCategory::Other,
        ),
        SkillInfo::new(
            "hope_genome_status",
            "AI Genom állapot",
            SkillCategory::Other,
        ),
        SkillInfo::new(
            "hope_genome_verify",
            "Akció etikai ellenőrzése",
            SkillCategory::Other,
        ),
        SkillInfo::new(
            "hope_alan_status",
            "ALAN önkódoló állapot",
            SkillCategory::Other,
        ),
        SkillInfo::new("hope_alan_analyze", "ALAN önelemzés", SkillCategory::Other),
        SkillInfo::new(
            "hope_plugin_list",
            "Plugin-ok listázása",
            SkillCategory::Other,
        ),
        SkillInfo::new("hope_plugin_load", "Plugin betöltése", SkillCategory::Other),
    ]
}

// ============================================================================
// TESTS
// ============================================================================

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_skill_category() {
        assert_eq!(SkillCategory::from("core"), SkillCategory::Core);
        assert_eq!(SkillCategory::from("memory"), SkillCategory::Memory);
        assert_eq!(SkillCategory::from("COGNITIVE"), SkillCategory::Cognitive);
        assert_eq!(SkillCategory::from("unknown"), SkillCategory::Other);
    }

    #[test]
    fn test_skill_info_creation() {
        let skill = SkillInfo::new("hope_test", "Test skill", SkillCategory::Core)
            .with_param(SkillParam {
                name: "input".to_string(),
                description: "Input param".to_string(),
                param_type: "string".to_string(),
                required: true,
                default: None,
            })
            .with_version("2.0.0");

        assert_eq!(skill.name, "hope_test");
        assert_eq!(skill.params.len(), 1);
        assert_eq!(skill.version, "2.0.0");
    }

    #[test]
    fn test_skill_result() {
        let success = SkillResult::success("OK");
        assert!(success.success);
        assert_eq!(success.output, "OK");

        let with_data = SkillResult::success_with_data("OK", serde_json::json!({"key": "value"}));
        assert!(with_data.data.is_some());

        let error = SkillResult::error("Failed");
        assert!(!error.success);
    }

    #[test]
    fn test_skill_success_rate() {
        let mut skill = SkillInfo::new("test", "Test", SkillCategory::Core);
        assert_eq!(skill.success_rate(), 0.0);

        skill.invocations = 10;
        skill.successes = 8;
        assert!((skill.success_rate() - 0.8).abs() < 0.001);
    }

    #[tokio::test]
    async fn test_skill_registry_creation() {
        let registry = SkillRegistry::new();

        // Wait for default skills to be registered
        tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;

        let stats = registry.get_stats().await;
        assert!(stats.total_skills > 0);
    }

    #[tokio::test]
    async fn test_skill_registration() {
        let registry = SkillRegistry::new();

        let skill = SkillInfo::new("custom_skill", "Custom skill", SkillCategory::Other);
        registry.register(skill, None).await;

        let retrieved = registry.get("custom_skill").await;
        assert!(retrieved.is_some());
        assert_eq!(retrieved.unwrap().name, "custom_skill");
    }

    #[tokio::test]
    async fn test_skill_listing() {
        let registry = SkillRegistry::new();
        tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;

        let all = registry.list(None, None).await;
        assert!(!all.is_empty());

        let core = registry.list(Some(SkillCategory::Core), None).await;
        assert!(core.iter().all(|s| s.category == SkillCategory::Core));

        let search = registry.list(None, Some("think")).await;
        assert!(search.iter().any(|s| s.name.contains("think")));
    }

    #[tokio::test]
    async fn test_skill_invocation() {
        let registry = SkillRegistry::new();
        tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;

        let result = registry
            .invoke("hope_status", "", &HashMap::new())
            .await
            .unwrap();

        assert!(result.success);
        assert!(result.execution_time_ms >= 0.0);
    }

    #[tokio::test]
    async fn test_skill_enable_disable() {
        let registry = SkillRegistry::new();
        tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;

        // Disable
        assert!(registry.set_enabled("hope_status", false).await);

        // Try to invoke
        let result = registry
            .invoke("hope_status", "", &HashMap::new())
            .await
            .unwrap();

        assert!(!result.success);
        assert!(result.output.contains("disabled"));

        // Re-enable
        registry.set_enabled("hope_status", true).await;
    }

    #[tokio::test]
    async fn test_categories_listing() {
        let registry = SkillRegistry::new();
        tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;

        let categories = registry.list_categories().await;
        assert!(!categories.is_empty());
    }

    #[test]
    fn test_default_skills_count() {
        let skills = default_skills();
        // Ellenőrizzük, hogy van elég skill
        assert!(
            skills.len() >= 50,
            "Expected at least 50 skills, got {}",
            skills.len()
        );
    }
}