1use std::{collections::HashMap, sync::OnceLock};
8
9#[derive(Debug, Clone, Copy)]
11pub struct BuiltinTemplate {
12 pub name: &'static str,
13 pub content: &'static str,
14 pub description: &'static str,
15}
16
17pub struct BuiltinTemplates;
19
20static TEMPLATES: OnceLock<HashMap<&'static str, BuiltinTemplate>> = OnceLock::new();
21
22impl BuiltinTemplates {
23 pub fn get_all() -> &'static HashMap<&'static str, BuiltinTemplate> {
25 TEMPLATES.get_or_init(|| {
26 HashMap::from([
27 (
28 "default-markdown",
29 BuiltinTemplate {
30 name: "Default (Markdown)",
31 content: include_str!("default_template_md.hbs"),
32 description: "Default markdown template for code analysis",
33 },
34 ),
35 (
36 "default-xml",
37 BuiltinTemplate {
38 name: "Default (XML)",
39 content: include_str!("default_template_xml.hbs"),
40 description: "Default XML template for code analysis",
41 },
42 ),
43 (
44 "binary-exploitation-ctf-solver",
45 BuiltinTemplate {
46 name: "Binary Exploitation CTF Solver",
47 content: include_str!("../templates/binary-exploitation-ctf-solver.hbs"),
48 description: "Template for solving binary exploitation CTF challenges",
49 },
50 ),
51 (
52 "clean-up-code",
53 BuiltinTemplate {
54 name: "Clean Up Code",
55 content: include_str!("../templates/clean-up-code.hbs"),
56 description: "Template for code cleanup and refactoring",
57 },
58 ),
59 (
60 "cryptography-ctf-solver",
61 BuiltinTemplate {
62 name: "Cryptography CTF Solver",
63 content: include_str!("../templates/cryptography-ctf-solver.hbs"),
64 description: "Template for solving cryptography CTF challenges",
65 },
66 ),
67 (
68 "document-the-code",
69 BuiltinTemplate {
70 name: "Document the Code",
71 content: include_str!("../templates/document-the-code.hbs"),
72 description: "Template for generating code documentation",
73 },
74 ),
75 (
76 "find-security-vulnerabilities",
77 BuiltinTemplate {
78 name: "Find Security Vulnerabilities",
79 content: include_str!("../templates/find-security-vulnerabilities.hbs"),
80 description: "Template for security vulnerability analysis",
81 },
82 ),
83 (
84 "fix-bugs",
85 BuiltinTemplate {
86 name: "Fix Bugs",
87 content: include_str!("../templates/fix-bugs.hbs"),
88 description: "Template for bug fixing and debugging",
89 },
90 ),
91 (
92 "improve-performance",
93 BuiltinTemplate {
94 name: "Improve Performance",
95 content: include_str!("../templates/improve-performance.hbs"),
96 description: "Template for performance optimization",
97 },
98 ),
99 (
100 "refactor",
101 BuiltinTemplate {
102 name: "Refactor",
103 content: include_str!("../templates/refactor.hbs"),
104 description: "Template for code refactoring",
105 },
106 ),
107 (
108 "reverse-engineering-ctf-solver",
109 BuiltinTemplate {
110 name: "Reverse Engineering CTF Solver",
111 content: include_str!("../templates/reverse-engineering-ctf-solver.hbs"),
112 description: "Template for solving reverse engineering CTF challenges",
113 },
114 ),
115 (
116 "web-ctf-solver",
117 BuiltinTemplate {
118 name: "Web CTF Solver",
119 content: include_str!("../templates/web-ctf-solver.hbs"),
120 description: "Template for solving web CTF challenges",
121 },
122 ),
123 (
124 "write-git-commit",
125 BuiltinTemplate {
126 name: "Write Git Commit",
127 content: include_str!("../templates/write-git-commit.hbs"),
128 description: "Template for generating git commit messages",
129 },
130 ),
131 (
132 "write-github-pull-request",
133 BuiltinTemplate {
134 name: "Write GitHub Pull Request",
135 content: include_str!("../templates/write-github-pull-request.hbs"),
136 description: "Template for generating GitHub pull request descriptions",
137 },
138 ),
139 (
140 "write-github-readme",
141 BuiltinTemplate {
142 name: "Write GitHub README",
143 content: include_str!("../templates/write-github-readme.hbs"),
144 description: "Template for generating GitHub README files",
145 },
146 ),
147 ])
148 })
149 }
150
151 pub fn get_template(key: &str) -> Option<BuiltinTemplate> {
153 Self::get_all().get(key).cloned()
154 }
155
156 pub fn get_template_keys() -> Vec<&'static str> {
158 Self::get_all().keys().copied().collect()
159 }
160
161 pub fn has_template(key: &str) -> bool {
163 Self::get_all().contains_key(key)
164 }
165}