jarvy 0.5.0

Jarvy is a fast, cross-platform CLI that installs and manages developer tools across macOS and Linux.
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
//! Built-in templates for common development stacks
//!
//! These templates are embedded in the binary and available offline.

#![allow(dead_code)] // Public API for template management

use super::schema::{Template, TemplateMeta, TemplateTools};
use std::collections::HashMap;

/// A built-in template with metadata
#[derive(Debug, Clone)]
pub struct BuiltinTemplate {
    pub name: &'static str,
    pub description: &'static str,
    pub category: &'static str,
    pub tools: &'static [(&'static str, &'static str)],
}

impl BuiltinTemplate {
    /// Convert to a full Template struct
    pub fn to_template(&self) -> Template {
        let mut tools = TemplateTools::new();
        for (name, version) in self.tools {
            tools.add(name, version);
        }

        Template {
            template: TemplateMeta {
                name: self.name.to_string(),
                description: self.description.to_string(),
                category: self.category.to_string(),
                tags: vec![],
                author: Some("Jarvy Team".to_string()),
                version: Some("1.0.0".to_string()),
                min_jarvy_version: Some("0.1.0".to_string()),
            },
            tools,
            hooks: HashMap::new(),
        }
    }
}

/// All built-in templates
pub const BUILTIN_TEMPLATES: &[BuiltinTemplate] = &[
    // Web Development
    BuiltinTemplate {
        name: "react",
        description: "Complete React development environment with modern tooling",
        category: "Web Development",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("eza", "latest"),
            ("fzf", "latest"),
            ("starship", "latest"),
            ("gh", "latest"),
            ("httpie", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "vue",
        description: "Vue.js development stack with Vite tooling",
        category: "Web Development",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("fzf", "latest"),
            ("gh", "latest"),
            ("httpie", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "nextjs",
        description: "Next.js full-stack template with deployment tooling",
        category: "Web Development",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("eza", "latest"),
            ("fzf", "latest"),
            ("starship", "latest"),
            ("gh", "latest"),
            ("httpie", "latest"),
            ("awscli", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "angular",
        description: "Angular development environment with TypeScript tooling",
        category: "Web Development",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("fzf", "latest"),
            ("gh", "latest"),
            ("httpie", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "svelte",
        description: "Svelte/SvelteKit stack with Vite and modern tooling",
        category: "Web Development",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("fzf", "latest"),
            ("gh", "latest"),
            ("httpie", "latest"),
        ],
    },
    // Backend
    BuiltinTemplate {
        name: "node-api",
        description: "Node.js API development with Express/Fastify patterns",
        category: "Backend",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("redis", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "go-api",
        description: "Go backend development with common CLI tools",
        category: "Backend",
        tools: &[
            ("go", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "rust-cli",
        description: "Rust CLI development with cargo extensions",
        category: "Backend",
        tools: &[
            ("rust", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "python-api",
        description: "Python/FastAPI development with virtual environment tools",
        category: "Backend",
        tools: &[
            ("python", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("redis", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "java-spring",
        description: "Java Spring Boot development with Maven/Gradle",
        category: "Backend",
        tools: &[
            ("java", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("redis", "latest"),
        ],
    },
    // .NET
    BuiltinTemplate {
        name: "dotnet-api",
        description: "ASP.NET Core Web API with EF Core migrations and the standard tool chain",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-console",
        description: "Minimal .NET console application toolkit (CLI / cron / one-shot job)",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-worker",
        description: ".NET Worker Service (BackgroundService) for queues, schedulers, and daemons",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("gh", "latest"),
            ("redis", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-grpc",
        description: "gRPC service in ASP.NET Core with protobuf tooling",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("grpcurl", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-mvc",
        description: "ASP.NET Core MVC web app with Razor views and EF Core",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-azure",
        description: "ASP.NET Core + Azure cloud-native toolkit (azd, bicep, az, EF Core)",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("azure_cli", "latest"),
            ("azd", "latest"),
            ("bicep", "latest"),
            ("gitversion", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "dotnet-microservices",
        description: "Distributed .NET microservices toolkit (Dapr, Docker, gRPC, EF Core, SQL)",
        category: "Backend",
        tools: &[
            ("dotnet", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("gh", "latest"),
            ("dapr", "latest"),
            ("grpcurl", "latest"),
            ("mssql_cli", "latest"),
            ("redis", "latest"),
        ],
    },
    // Messaging
    BuiltinTemplate {
        name: "nats-services",
        description: "NATS-based microservices toolkit (broker, CLI, auth, gRPC, Docker)",
        category: "Backend",
        tools: &[
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("httpie", "latest"),
            ("gh", "latest"),
            ("nats", "latest"),
            ("nats_server", "latest"),
            ("nsc", "latest"),
            ("grpcurl", "latest"),
        ],
    },
    // Data & ML
    BuiltinTemplate {
        name: "python-ml",
        description: "Python ML/Data Science with Jupyter and scientific tools",
        category: "Data & ML",
        tools: &[
            ("python", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("gh", "latest"),
            ("awscli", "latest"),
            ("duckdb", "latest"),
            ("bat", "latest"),
            ("fzf", "latest"),
            ("httpie", "latest"),
            ("sqlite", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "jupyter",
        description: "Jupyter notebook environment with essential data tools",
        category: "Data & ML",
        tools: &[
            ("python", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("gh", "latest"),
            ("duckdb", "latest"),
            ("sqlite", "latest"),
        ],
    },
    // DevOps
    BuiltinTemplate {
        name: "k8s-admin",
        description: "Kubernetes administration with cluster management tools",
        category: "DevOps",
        tools: &[
            ("kubectl", "latest"),
            ("helm", "latest"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("k9s", "latest"),
            ("stern", "latest"),
            ("kubectx", "latest"),
            ("gh", "latest"),
            ("awscli", "latest"),
            ("yq", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "terraform",
        description: "Infrastructure as Code with Terraform and cloud CLIs",
        category: "DevOps",
        tools: &[
            ("terraform", "latest"),
            ("git", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("gh", "latest"),
            ("awscli", "latest"),
            ("yq", "latest"),
            ("terragrunt", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "docker-dev",
        description: "Docker development with compose and debugging tools",
        category: "DevOps",
        tools: &[
            ("docker", "latest"),
            ("git", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("dive", "latest"),
            ("lazydocker", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "cicd",
        description: "CI/CD pipeline tools for building and deploying",
        category: "DevOps",
        tools: &[
            ("git", "latest"),
            ("docker", "latest"),
            ("gh", "latest"),
            ("jq", "latest"),
            ("yq", "latest"),
            ("act", "latest"),
            ("awscli", "latest"),
            ("trivy", "latest"),
        ],
    },
    // Mobile
    BuiltinTemplate {
        name: "flutter",
        description: "Flutter cross-platform development with mobile tooling",
        category: "Mobile",
        tools: &[
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("gh", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "react-native",
        description: "React Native mobile development with iOS/Android tooling",
        category: "Mobile",
        tools: &[
            ("node", "20"),
            ("git", "latest"),
            ("docker", "latest"),
            ("jq", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("gh", "latest"),
        ],
    },
    // Minimal
    BuiltinTemplate {
        name: "essential",
        description: "Minimal toolkit with git, editor support, and shell tools",
        category: "Minimal",
        tools: &[
            ("git", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("jq", "latest"),
        ],
    },
    BuiltinTemplate {
        name: "shell-power",
        description: "Power shell user toolkit with productivity enhancers",
        category: "Minimal",
        tools: &[
            ("git", "latest"),
            ("ripgrep", "latest"),
            ("fd", "latest"),
            ("bat", "latest"),
            ("eza", "latest"),
            ("fzf", "latest"),
            ("starship", "latest"),
            ("zoxide", "latest"),
        ],
    },
];

/// Get a built-in template by name
pub fn get_builtin_template(name: &str) -> Option<&'static BuiltinTemplate> {
    BUILTIN_TEMPLATES.iter().find(|t| t.name == name)
}

/// List all built-in templates
pub fn list_builtin_templates() -> &'static [BuiltinTemplate] {
    BUILTIN_TEMPLATES
}

/// Get templates by category
pub fn templates_by_category(category: &str) -> Vec<&'static BuiltinTemplate> {
    BUILTIN_TEMPLATES
        .iter()
        .filter(|t| t.category.eq_ignore_ascii_case(category))
        .collect()
}

/// Get all unique categories
pub fn all_categories() -> Vec<&'static str> {
    let mut categories: Vec<&str> = BUILTIN_TEMPLATES.iter().map(|t| t.category).collect();
    categories.sort();
    categories.dedup();
    categories
}

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

    #[test]
    fn test_get_builtin_template() {
        let template = get_builtin_template("react").unwrap();
        assert_eq!(template.name, "react");
        assert!(!template.tools.is_empty());
    }

    #[test]
    fn test_get_nonexistent_template() {
        assert!(get_builtin_template("nonexistent").is_none());
    }

    #[test]
    fn test_list_builtin_templates() {
        let templates = list_builtin_templates();
        assert!(!templates.is_empty());
        assert!(templates.len() >= 20);
    }

    #[test]
    fn test_templates_by_category() {
        let web_templates = templates_by_category("Web Development");
        assert!(!web_templates.is_empty());
        assert!(web_templates.iter().any(|t| t.name == "react"));
    }

    /// Every (tool name) entry in a builtin template MUST be a name
    /// the tool registry knows about. A typo at the template-definition
    /// site (`("dontet", "latest")` or `("grpculr", "latest")`) would
    /// otherwise ship a template that runs `jarvy setup` and silently
    /// does nothing — `setup` emits `tool.unsupported` for the unknown
    /// name and continues. The validator catches this for user-authored
    /// configs; this test gives the same protection to the templates
    /// the team ships.
    #[test]
    fn every_builtin_template_tool_is_registered() {
        use std::collections::HashSet;
        crate::tools::register_all();
        let known: HashSet<String> = crate::tools::registered_tool_names()
            .into_iter()
            .map(|n| n.to_lowercase())
            .collect();
        let mut failures: Vec<String> = Vec::new();
        for t in BUILTIN_TEMPLATES {
            for (name, _) in t.tools {
                if !known.contains(&name.to_lowercase()) {
                    failures.push(format!(
                        "template `{}` references unregistered tool `{}`",
                        t.name, name
                    ));
                }
            }
        }
        assert!(
            failures.is_empty(),
            "builtin templates reference tools not in registry:\n  - {}",
            failures.join("\n  - ")
        );
    }

    #[test]
    fn test_all_categories() {
        let categories = all_categories();
        assert!(categories.contains(&"Web Development"));
        assert!(categories.contains(&"Backend"));
        assert!(categories.contains(&"DevOps"));
    }

    #[test]
    fn test_builtin_template_to_template() {
        let builtin = get_builtin_template("essential").unwrap();
        let template = builtin.to_template();
        assert_eq!(template.name(), "essential");
        assert_eq!(template.tool_count(), 5);
    }
}