raz-core 0.2.4

Universal command generator for Rust projects - Core library with stateless file analysis and cursor-aware execution
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
//! Framework detection with precise pattern matching and scoring
//!
//! This module provides laser-precise framework detection by analyzing:
//! - Dependencies and their combinations
//! - Project structure patterns
//! - File names and locations
//! - Function contexts
//! - Configuration files

use crate::ProjectContext;
use std::collections::HashMap;
use std::path::Path;

/// Framework types that can be detected
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FrameworkType {
    LeptosSSR,
    LeptosCSR,
    DioxusWeb,
    DioxusDesktop,
    DioxusMobile,
    BevyGame,
    TauriDesktop,
    ActixWeb,
    Axum,
    Rocket,
    YewWeb,
    EguiDesktop,
    WasmPack,
    VanillaRust,
}

/// Detection confidence score
#[derive(Debug, Clone)]
pub struct DetectionScore {
    pub framework: FrameworkType,
    pub confidence: f32,
    pub reasons: Vec<String>,
}

/// Framework detection engine with precise pattern matching
pub struct PreciseFrameworkDetector {
    patterns: HashMap<FrameworkType, FrameworkPattern>,
}

/// Pattern definition for framework detection
#[derive(Debug, Clone)]
struct FrameworkPattern {
    /// Required dependencies (all must be present)
    required_deps: Vec<&'static str>,
    /// Optional dependencies that increase confidence
    optional_deps: Vec<&'static str>,
    /// File structure patterns
    file_patterns: Vec<&'static str>,
    /// Configuration file patterns
    config_files: Vec<&'static str>,
    /// Typical entry point patterns
    entry_points: Vec<&'static str>,
    /// Weight for this framework (higher = more specific)
    specificity: f32,
}

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

impl PreciseFrameworkDetector {
    pub fn new() -> Self {
        let mut patterns = HashMap::new();

        // Leptos SSR pattern (most specific)
        patterns.insert(
            FrameworkType::LeptosSSR,
            FrameworkPattern {
                required_deps: vec!["leptos", "leptos_axum"],
                optional_deps: vec![
                    "leptos_meta",
                    "leptos_router",
                    "axum",
                    "tokio",
                    "tower",
                    "tower-http",
                ],
                file_patterns: vec![
                    "app/src/lib.rs",
                    "frontend/src/lib.rs",
                    "server/src/main.rs",
                    "style/main.scss",
                    "Cargo.toml",
                ],
                config_files: vec!["Cargo.toml", "Trunk.toml", "style.css"],
                entry_points: vec!["server/src/main.rs", "src/main.rs"],
                specificity: 10.0,
            },
        );

        // Leptos CSR pattern
        patterns.insert(
            FrameworkType::LeptosCSR,
            FrameworkPattern {
                required_deps: vec!["leptos"],
                optional_deps: vec!["leptos_meta", "leptos_router", "wasm-bindgen", "web-sys"],
                file_patterns: vec!["src/main.rs", "src/app.rs", "index.html", "Trunk.toml"],
                config_files: vec!["Trunk.toml", "index.html"],
                entry_points: vec!["src/main.rs"],
                specificity: 8.0,
            },
        );

        // Dioxus Web pattern - matches both separate crates and features
        patterns.insert(
            FrameworkType::DioxusWeb,
            FrameworkPattern {
                required_deps: vec!["dioxus"],
                optional_deps: vec![
                    "dioxus-web",
                    "dioxus-router",
                    "dioxus-hooks",
                    "wasm-bindgen",
                ],
                file_patterns: vec!["src/main.rs", "index.html", "Dioxus.toml"],
                config_files: vec!["Dioxus.toml"],
                entry_points: vec!["src/main.rs"],
                specificity: 8.0,
            },
        );

        // Dioxus Desktop pattern - matches both separate crates and features
        patterns.insert(
            FrameworkType::DioxusDesktop,
            FrameworkPattern {
                required_deps: vec!["dioxus"],
                optional_deps: vec!["dioxus-desktop", "dioxus-router", "dioxus-hooks"],
                file_patterns: vec!["src/main.rs", "Dioxus.toml"],
                config_files: vec!["Dioxus.toml"],
                entry_points: vec!["src/main.rs"],
                specificity: 8.0,
            },
        );

        // Dioxus Mobile pattern - matches both separate crates and features
        patterns.insert(
            FrameworkType::DioxusMobile,
            FrameworkPattern {
                required_deps: vec!["dioxus"],
                optional_deps: vec!["dioxus-mobile", "dioxus-router", "dioxus-hooks"],
                file_patterns: vec!["src/main.rs", "Dioxus.toml"],
                config_files: vec!["Dioxus.toml"],
                entry_points: vec!["src/main.rs"],
                specificity: 8.0,
            },
        );

        // Bevy game pattern
        patterns.insert(
            FrameworkType::BevyGame,
            FrameworkPattern {
                required_deps: vec!["bevy"],
                optional_deps: vec!["bevy_egui", "bevy_rapier3d", "bevy_rapier2d"],
                file_patterns: vec!["src/main.rs", "assets/"],
                config_files: vec![],
                entry_points: vec!["src/main.rs"],
                specificity: 7.0,
            },
        );

        // Tauri desktop pattern
        patterns.insert(
            FrameworkType::TauriDesktop,
            FrameworkPattern {
                required_deps: vec!["tauri"],
                optional_deps: vec!["serde", "serde_json", "tokio", "tauri-build"],
                file_patterns: vec![
                    "src-tauri/src/main.rs",
                    "src-tauri/tauri.conf.json",
                    "src/main.rs",     // When running from within src-tauri
                    "tauri.conf.json", // When running from within src-tauri
                    "src/main.js",
                    "index.html",
                ],
                config_files: vec!["src-tauri/tauri.conf.json", "tauri.conf.json"],
                entry_points: vec!["src-tauri/src/main.rs", "src/main.rs"],
                specificity: 9.5, // High specificity for Tauri
            },
        );

        // Actix Web pattern
        patterns.insert(
            FrameworkType::ActixWeb,
            FrameworkPattern {
                required_deps: vec!["actix-web"],
                optional_deps: vec!["actix-rt", "actix-cors", "actix-session"],
                file_patterns: vec!["src/main.rs"],
                config_files: vec![],
                entry_points: vec!["src/main.rs"],
                specificity: 5.0,
            },
        );

        // Axum pattern (without Leptos)
        patterns.insert(
            FrameworkType::Axum,
            FrameworkPattern {
                required_deps: vec!["axum"],
                optional_deps: vec!["tower", "tower-http", "tokio"],
                file_patterns: vec!["src/main.rs"],
                config_files: vec![],
                entry_points: vec!["src/main.rs"],
                specificity: 4.0, // Lower than Leptos SSR which also uses Axum
            },
        );

        // Rocket pattern
        patterns.insert(
            FrameworkType::Rocket,
            FrameworkPattern {
                required_deps: vec!["rocket"],
                optional_deps: vec!["rocket_contrib", "serde", "serde_json"],
                file_patterns: vec!["src/main.rs", "Rocket.toml"],
                config_files: vec!["Rocket.toml"],
                entry_points: vec!["src/main.rs"],
                specificity: 6.0,
            },
        );

        // Yew pattern
        patterns.insert(
            FrameworkType::YewWeb,
            FrameworkPattern {
                required_deps: vec!["yew"],
                optional_deps: vec!["yew-router", "wasm-bindgen", "web-sys", "js-sys"],
                file_patterns: vec![
                    "src/main.rs",
                    "index.html",
                    "Trunk.toml",
                    "index.scss",
                    "style.css",
                ],
                config_files: vec!["Trunk.toml", "index.html"],
                entry_points: vec!["src/main.rs"],
                specificity: 9.0, // High specificity for Yew projects
            },
        );

        // Egui Desktop pattern
        patterns.insert(
            FrameworkType::EguiDesktop,
            FrameworkPattern {
                required_deps: vec!["egui", "eframe"],
                optional_deps: vec!["egui_extras"],
                file_patterns: vec!["src/main.rs"],
                config_files: vec![],
                entry_points: vec!["src/main.rs"],
                specificity: 6.0,
            },
        );

        // WASM Pack pattern
        patterns.insert(
            FrameworkType::WasmPack,
            FrameworkPattern {
                required_deps: vec!["wasm-bindgen"],
                optional_deps: vec!["web-sys", "js-sys", "wasm-bindgen-futures"],
                file_patterns: vec!["src/lib.rs", "Cargo.toml", "pkg/"],
                config_files: vec![],
                entry_points: vec!["src/lib.rs"],
                specificity: 5.0,
            },
        );

        Self { patterns }
    }

    /// Detect framework with scoring algorithm
    pub fn detect(
        &self,
        context: &ProjectContext,
        file_path: Option<&Path>,
    ) -> Vec<DetectionScore> {
        let mut scores = Vec::new();

        for (framework, pattern) in &self.patterns {
            let mut score = 0.0;
            let mut reasons = Vec::new();

            // Check required dependencies (must have all)
            let has_all_required = pattern
                .required_deps
                .iter()
                .all(|dep| context.dependencies.iter().any(|d| d.name == *dep));

            if !has_all_required {
                continue; // Skip this framework if missing required deps
            }

            score += pattern.specificity;
            reasons.push(format!(
                "Has all required dependencies: {:?}",
                pattern.required_deps
            ));

            // Check optional dependencies (bonus points)
            let optional_count = pattern
                .optional_deps
                .iter()
                .filter(|dep| context.dependencies.iter().any(|d| d.name == **dep))
                .count();

            if optional_count > 0 {
                score += optional_count as f32 * 0.5;
                reasons.push(format!("Has {optional_count} optional dependencies"));
            }

            // Check file structure patterns
            let file_pattern_matches = pattern
                .file_patterns
                .iter()
                .filter(|pattern| {
                    let path = context.workspace_root.join(pattern);
                    path.exists()
                })
                .count();

            if file_pattern_matches > 0 {
                score += file_pattern_matches as f32 * 1.0;
                reasons.push(format!(
                    "Matches {file_pattern_matches} file structure patterns"
                ));
            }

            // Check config files
            let config_matches = pattern
                .config_files
                .iter()
                .filter(|config| {
                    let path = context.workspace_root.join(config);
                    path.exists()
                })
                .count();

            if config_matches > 0 {
                score += config_matches as f32 * 2.0;
                reasons.push(format!("Has {config_matches} config files"));
            }

            // Check if current file matches entry point
            if let Some(current_file) = file_path {
                for entry_point in &pattern.entry_points {
                    let entry_path = context.workspace_root.join(entry_point);
                    if current_file == entry_path {
                        score += 3.0;
                        reasons.push(format!("Current file is entry point: {entry_point}"));
                        break;
                    }
                }
            }

            // Special case: Leptos SSR structure detection
            if framework == &FrameworkType::LeptosSSR {
                // Check for typical Leptos SSR workspace structure
                let has_app_crate = context.workspace_members.iter().any(|m| m.name == "app");
                let has_frontend_crate = context
                    .workspace_members
                    .iter()
                    .any(|m| m.name == "frontend");
                let has_server_crate = context.workspace_members.iter().any(|m| m.name == "server");

                if has_app_crate || has_frontend_crate {
                    score += 2.0;
                    reasons
                        .push("Has Leptos workspace structure (app/frontend crates)".to_string());
                }

                if has_server_crate {
                    score += 2.0;
                    reasons.push("Has server crate typical of Leptos SSR".to_string());
                }
            }

            // Special case: Dioxus platform detection
            if framework == &FrameworkType::DioxusDesktop
                || framework == &FrameworkType::DioxusWeb
                || framework == &FrameworkType::DioxusMobile
            {
                score += self.detect_dioxus_platform_specifics(context, framework, &mut reasons);
            }

            scores.push(DetectionScore {
                framework: framework.clone(),
                confidence: score,
                reasons,
            });
        }

        // Sort by confidence (highest first)
        scores.sort_by(|a, b| b.confidence.partial_cmp(&a.confidence).unwrap());

        scores
    }

    /// Detect Dioxus platform-specific features and configuration
    fn detect_dioxus_platform_specifics(
        &self,
        context: &ProjectContext,
        framework: &FrameworkType,
        reasons: &mut Vec<String>,
    ) -> f32 {
        let mut bonus_score = 0.0;

        // Check workspace structure for platform-specific folders
        for member in &context.workspace_members {
            let member_name = member.name.to_lowercase();
            let path_name = member
                .path
                .file_name()
                .and_then(|name| name.to_str())
                .unwrap_or("")
                .to_lowercase();

            match framework {
                FrameworkType::DioxusWeb => {
                    if member_name.contains("web") || path_name.contains("web") {
                        bonus_score += 5.0;
                        reasons.push(format!("Found web workspace member: {}", member.name));
                    }
                }
                FrameworkType::DioxusDesktop => {
                    if member_name.contains("desktop") || path_name.contains("desktop") {
                        bonus_score += 5.0;
                        reasons.push(format!("Found desktop workspace member: {}", member.name));
                    }
                }
                FrameworkType::DioxusMobile => {
                    if member_name.contains("mobile") || path_name.contains("mobile") {
                        bonus_score += 5.0;
                        reasons.push(format!("Found mobile workspace member: {}", member.name));
                    }
                }
                _ => {}
            }
        }

        // Check for Dioxus.toml configuration
        let dioxus_toml_path = context.workspace_root.join("Dioxus.toml");
        if dioxus_toml_path.exists() {
            bonus_score += 2.0;
            reasons.push("Has Dioxus.toml configuration file".to_string());

            // Parse Dioxus.toml to check default_platform
            if let Ok(content) = std::fs::read_to_string(&dioxus_toml_path) {
                if let Ok(config) = content.parse::<toml::Value>() {
                    if let Some(app_config) = config.get("application") {
                        if let Some(default_platform) = app_config.get("default_platform") {
                            if let Some(platform_str) = default_platform.as_str() {
                                match (framework, platform_str) {
                                    (FrameworkType::DioxusDesktop, "desktop") => {
                                        bonus_score += 3.0;
                                        reasons.push(
                                            "Dioxus.toml specifies desktop platform".to_string(),
                                        );
                                    }
                                    (FrameworkType::DioxusWeb, "web") => {
                                        bonus_score += 3.0;
                                        reasons
                                            .push("Dioxus.toml specifies web platform".to_string());
                                    }
                                    (FrameworkType::DioxusMobile, "mobile") => {
                                        bonus_score += 3.0;
                                        reasons.push(
                                            "Dioxus.toml specifies mobile platform".to_string(),
                                        );
                                    }
                                    _ => {}
                                }
                            }
                        }
                    }
                }
            }
        }

        // Check for Dioxus features in dependencies
        if let Some(dioxus_dep) = context.dependencies.iter().find(|d| d.name == "dioxus") {
            match framework {
                FrameworkType::DioxusDesktop => {
                    if dioxus_dep.features.contains(&"desktop".to_string()) {
                        bonus_score += 3.0;
                        reasons.push("Dioxus dependency has 'desktop' feature".to_string());
                    }
                }
                FrameworkType::DioxusWeb => {
                    if dioxus_dep.features.contains(&"web".to_string()) {
                        bonus_score += 3.0;
                        reasons.push("Dioxus dependency has 'web' feature".to_string());
                    }
                }
                FrameworkType::DioxusMobile => {
                    if dioxus_dep.features.contains(&"mobile".to_string()) {
                        bonus_score += 3.0;
                        reasons.push("Dioxus dependency has 'mobile' feature".to_string());
                    }
                }
                _ => {}
            }

            // Check for fullstack feature (indicates complex setup)
            if dioxus_dep.features.contains(&"fullstack".to_string()) {
                bonus_score += 1.0;
                reasons.push("Dioxus dependency has 'fullstack' feature".to_string());
            }
        }

        // Check default features in Cargo.toml
        // Parse Cargo.toml to check if mobile is in default features
        let cargo_toml_path = context.workspace_root.join("Cargo.toml");
        if cargo_toml_path.exists() {
            if let Ok(content) = std::fs::read_to_string(&cargo_toml_path) {
                if let Ok(config) = content.parse::<toml::Value>() {
                    if let Some(features) = config.get("features") {
                        if let Some(default_features) = features.get("default") {
                            if let Some(default_array) = default_features.as_array() {
                                let default_feature_names: Vec<String> = default_array
                                    .iter()
                                    .filter_map(|v| v.as_str().map(|s| s.to_string()))
                                    .collect();

                                match framework {
                                    FrameworkType::DioxusMobile => {
                                        if default_feature_names.contains(&"mobile".to_string()) {
                                            bonus_score += 4.0;
                                            reasons
                                                .push("Mobile is in default features".to_string());
                                        }
                                    }
                                    FrameworkType::DioxusDesktop => {
                                        if default_feature_names.contains(&"desktop".to_string()) {
                                            bonus_score += 4.0;
                                            reasons
                                                .push("Desktop is in default features".to_string());
                                        }
                                        // Desktop is common default, give small bonus
                                        if default_feature_names.is_empty() {
                                            bonus_score += 1.0;
                                        }
                                    }
                                    FrameworkType::DioxusWeb => {
                                        if default_feature_names.contains(&"web".to_string()) {
                                            bonus_score += 4.0;
                                            reasons.push("Web is in default features".to_string());
                                        }
                                    }
                                    _ => {}
                                }
                            }
                        }
                    }
                }
            }
        }

        bonus_score
    }

    /// Get the best match with minimum confidence threshold
    pub fn best_match(
        &self,
        context: &ProjectContext,
        file_path: Option<&Path>,
        min_confidence: f32,
    ) -> Option<FrameworkType> {
        let scores = self.detect(context, file_path);

        scores
            .first()
            .filter(|s| s.confidence >= min_confidence)
            .map(|s| s.framework.clone())
    }
}

impl FrameworkType {
    /// Check if this is a web framework
    pub fn is_web_framework(&self) -> bool {
        matches!(
            self,
            FrameworkType::LeptosSSR
                | FrameworkType::LeptosCSR
                | FrameworkType::DioxusWeb
                | FrameworkType::YewWeb
                | FrameworkType::ActixWeb
                | FrameworkType::Axum
                | FrameworkType::Rocket
        )
    }

    /// Get the primary run command for this framework
    pub fn primary_run_command(&self) -> (&'static str, Vec<&'static str>) {
        match self {
            FrameworkType::LeptosSSR => ("cargo", vec!["leptos", "watch"]),
            FrameworkType::LeptosCSR => ("trunk", vec!["serve"]),
            FrameworkType::DioxusWeb => ("dx", vec!["serve"]),
            FrameworkType::DioxusDesktop => ("dx", vec!["serve", "--platform", "desktop"]),
            FrameworkType::DioxusMobile => ("dx", vec!["serve", "--platform", "mobile"]),
            FrameworkType::BevyGame => ("cargo", vec!["run"]),
            FrameworkType::TauriDesktop => ("cargo", vec!["tauri", "dev"]),
            FrameworkType::ActixWeb => ("cargo", vec!["run"]),
            FrameworkType::Axum => ("cargo", vec!["run"]),
            FrameworkType::Rocket => ("cargo", vec!["run"]),
            FrameworkType::YewWeb => ("trunk", vec!["serve"]),
            FrameworkType::EguiDesktop => ("cargo", vec!["run"]),
            FrameworkType::WasmPack => ("wasm-pack", vec!["build"]),
            FrameworkType::VanillaRust => ("cargo", vec!["run"]),
        }
    }

    /// Get the build command for this framework
    pub fn build_command(&self) -> (&'static str, Vec<&'static str>) {
        match self {
            FrameworkType::LeptosSSR => ("cargo", vec!["leptos", "build", "--release"]),
            FrameworkType::LeptosCSR => ("trunk", vec!["build", "--release"]),
            FrameworkType::DioxusWeb => ("dx", vec!["build", "--release"]),
            FrameworkType::DioxusDesktop => ("dx", vec!["build", "--release"]),
            FrameworkType::DioxusMobile => {
                ("dx", vec!["build", "--release", "--platform", "mobile"])
            }
            FrameworkType::BevyGame => ("cargo", vec!["build", "--release"]),
            FrameworkType::TauriDesktop => ("cargo", vec!["tauri", "build"]),
            FrameworkType::ActixWeb => ("cargo", vec!["build", "--release"]),
            FrameworkType::Axum => ("cargo", vec!["build", "--release"]),
            FrameworkType::Rocket => ("cargo", vec!["build", "--release"]),
            FrameworkType::YewWeb => ("trunk", vec!["build", "--release"]),
            FrameworkType::EguiDesktop => ("cargo", vec!["build", "--release"]),
            FrameworkType::WasmPack => ("wasm-pack", vec!["build", "--release"]),
            FrameworkType::VanillaRust => ("cargo", vec!["build", "--release"]),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::{Dependency, ProjectType, WorkspaceMember};
    use std::path::PathBuf;

    #[test]
    fn test_leptos_ssr_detection() {
        let detector = PreciseFrameworkDetector::new();

        let context = ProjectContext {
            workspace_root: PathBuf::from("/test/project"),
            current_file: None,
            cursor_position: None,
            project_type: ProjectType::Binary,
            dependencies: vec![
                Dependency {
                    name: "leptos".to_string(),
                    version: "0.5.0".to_string(),
                    features: vec![],
                    optional: false,
                    dev_dependency: false,
                },
                Dependency {
                    name: "leptos_axum".to_string(),
                    version: "0.5.0".to_string(),
                    features: vec![],
                    optional: false,
                    dev_dependency: false,
                },
                Dependency {
                    name: "axum".to_string(),
                    version: "0.6.0".to_string(),
                    features: vec![],
                    optional: false,
                    dev_dependency: false,
                },
            ],
            workspace_members: vec![
                WorkspaceMember {
                    name: "app".to_string(),
                    path: PathBuf::from("app"),
                    package_type: ProjectType::Library,
                },
                WorkspaceMember {
                    name: "server".to_string(),
                    path: PathBuf::from("server"),
                    package_type: ProjectType::Binary,
                },
            ],
            build_targets: vec![],
            active_features: vec![],
            env_vars: std::collections::HashMap::new(),
        };

        let scores = detector.detect(&context, None);
        assert!(!scores.is_empty());
        assert_eq!(scores[0].framework, FrameworkType::LeptosSSR);
        assert!(scores[0].confidence > 10.0);
    }
}