llm_coding_tools_core/context/
mod.rs1pub const BASH: &str = include_str!("bash.txt");
28
29pub const GIT_WORKFLOW: &str = include_str!("git_workflow.txt");
34
35pub const GITHUB_CLI: &str = include_str!("github_cli.txt");
40
41pub const TODO_READ: &str = include_str!("todoread.txt");
43
44pub const TODO_WRITE: &str = include_str!("todowrite.txt");
46
47pub const WEBFETCH: &str = include_str!("webfetch.txt");
49
50pub const READ_ABSOLUTE: &str = include_str!("read_absolute.txt");
52
53pub const READ_ALLOWED: &str = include_str!("read_allowed.txt");
55
56pub const WRITE_ABSOLUTE: &str = include_str!("write_absolute.txt");
58
59pub const WRITE_ALLOWED: &str = include_str!("write_allowed.txt");
61
62pub const EDIT_ABSOLUTE: &str = include_str!("edit_absolute.txt");
64
65pub const EDIT_ALLOWED: &str = include_str!("edit_allowed.txt");
67
68pub const GLOB_ABSOLUTE: &str = include_str!("glob_absolute.txt");
70
71pub const GLOB_ALLOWED: &str = include_str!("glob_allowed.txt");
73
74pub const GREP_ABSOLUTE: &str = include_str!("grep_absolute.txt");
76
77pub const GREP_ALLOWED: &str = include_str!("grep_allowed.txt");
79
80pub trait ToolContext {
101 const NAME: &'static str;
106
107 fn context(&self) -> &'static str;
111}
112
113#[cfg(test)]
114mod tests {
115 use super::*;
116
117 #[test]
118 fn context_strings_are_not_empty() {
119 assert!(!BASH.is_empty(), "BASH context should not be empty");
121 assert!(
122 !GIT_WORKFLOW.is_empty(),
123 "GIT_WORKFLOW context should not be empty"
124 );
125 assert!(
126 !GITHUB_CLI.is_empty(),
127 "GITHUB_CLI context should not be empty"
128 );
129 assert!(
130 !TODO_READ.is_empty(),
131 "TODO_READ context should not be empty"
132 );
133 assert!(
134 !TODO_WRITE.is_empty(),
135 "TODO_WRITE context should not be empty"
136 );
137 assert!(!WEBFETCH.is_empty(), "WEBFETCH context should not be empty");
138
139 assert!(
141 !READ_ABSOLUTE.is_empty(),
142 "READ_ABSOLUTE context should not be empty"
143 );
144 assert!(
145 !WRITE_ABSOLUTE.is_empty(),
146 "WRITE_ABSOLUTE context should not be empty"
147 );
148 assert!(
149 !EDIT_ABSOLUTE.is_empty(),
150 "EDIT_ABSOLUTE context should not be empty"
151 );
152 assert!(
153 !GLOB_ABSOLUTE.is_empty(),
154 "GLOB_ABSOLUTE context should not be empty"
155 );
156 assert!(
157 !GREP_ABSOLUTE.is_empty(),
158 "GREP_ABSOLUTE context should not be empty"
159 );
160
161 assert!(
163 !READ_ALLOWED.is_empty(),
164 "READ_ALLOWED context should not be empty"
165 );
166 assert!(
167 !WRITE_ALLOWED.is_empty(),
168 "WRITE_ALLOWED context should not be empty"
169 );
170 assert!(
171 !EDIT_ALLOWED.is_empty(),
172 "EDIT_ALLOWED context should not be empty"
173 );
174 assert!(
175 !GLOB_ALLOWED.is_empty(),
176 "GLOB_ALLOWED context should not be empty"
177 );
178 assert!(
179 !GREP_ALLOWED.is_empty(),
180 "GREP_ALLOWED context should not be empty"
181 );
182 }
183
184 #[test]
185 fn absolute_variants_mention_absolute_path() {
186 assert!(
187 READ_ABSOLUTE.contains("absolute path"),
188 "READ_ABSOLUTE should mention absolute path"
189 );
190 }
191
192 #[test]
193 fn allowed_variants_mention_allowed_directories() {
194 assert!(
195 READ_ALLOWED.contains("allowed directories"),
196 "READ_ALLOWED should mention allowed directories"
197 );
198 assert!(
199 WRITE_ALLOWED.contains("allowed directories"),
200 "WRITE_ALLOWED should mention allowed directories"
201 );
202 assert!(
203 EDIT_ALLOWED.contains("allowed directories"),
204 "EDIT_ALLOWED should mention allowed directories"
205 );
206 assert!(
207 GLOB_ALLOWED.contains("allowed directories"),
208 "GLOB_ALLOWED should mention allowed directories"
209 );
210 assert!(
211 GREP_ALLOWED.contains("allowed directories"),
212 "GREP_ALLOWED should mention allowed directories"
213 );
214 }
215
216 #[test]
217 fn git_workflow_contains_expected_content() {
218 assert!(
219 GIT_WORKFLOW.contains("git commit"),
220 "GIT_WORKFLOW should mention git commit"
221 );
222 assert!(
223 GIT_WORKFLOW.contains("NEVER"),
224 "GIT_WORKFLOW should contain safety rules"
225 );
226 }
227
228 #[test]
229 fn github_cli_contains_expected_content() {
230 assert!(
231 GITHUB_CLI.contains("gh "),
232 "GITHUB_CLI should mention gh command"
233 );
234 assert!(
235 GITHUB_CLI.contains("pull request"),
236 "GITHUB_CLI should mention pull requests"
237 );
238 }
239
240 #[test]
241 fn bash_does_not_contain_git_workflow() {
242 assert!(
243 !BASH.contains("# Committing changes with git"),
244 "BASH should not contain git workflow section"
245 );
246 }
247
248 #[test]
249 fn bash_does_not_contain_github_cli() {
250 assert!(
251 !BASH.contains("# Creating pull requests"),
252 "BASH should not contain GitHub CLI section"
253 );
254 }
255}