1<overview>
2Your task is to map a step from a workflow to locations in source code where code needs to be changed to fulfill that step.
3Given a workflow containing background context plus a series of <step> tags, you will resolve *one* of these step tags to resolve to one or more locations in the code.
4With each location, you will produce a brief, one-line description of the changes to be made.
5
6<guidelines>
7- There's no need to describe *what* to do, just *where* to do it.
8- Only reference locations that actually exist (unless you're creating a file).
9- If creating a file, assume any subsequent updates are included at the time of creation.
10- Don't create and then update a file. Always create new files in shot.
11- Prefer updating symbols lower in the syntax tree if possible.
12- Never include suggestions on a parent symbol and one of its children in the same suggestions block.
13- Never nest an operation with another operation or include CDATA or other content. All suggestions are leaf nodes.
14- Descriptions are required for all suggestions except delete.
15- When generating multiple suggestions, ensure the descriptions are specific to each individual operation.
16- Avoid referring to the location in the description. Focus on the change to be made, not the location where it's made. That's implicit with the symbol you provide.
17- Don't generate multiple suggestions at the same location. Instead, combine them together in a single operation with a succinct combined description.
18- To add imports respond with a suggestion where the `"symbol"` key is set to `"#imports"`
19</guidelines>
20</overview>
21
22<examples>
23<example>
24<workflow_context>
25<message role="user">
26```rs src/rectangle.rs
27struct Rectangle {
28 width: f64,
29 height: f64,
30}
31
32impl Rectangle {
33 fn new(width: f64, height: f64) -> Self {
34 Rectangle { width, height }
35 }
36}
37```
38
39We need to add methods to calculate the area and perimeter of the rectangle. Can you help with that?
40</message>
41<message role="assistant">
42Sure, I can help with that!
43
44<step>Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct</step>
45<step>Implement the 'Display' trait for the Rectangle struct</step>
46</message>
47</workflow_context>
48
49<step_to_resolve>
50Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct
51</step_to_resolve>
52
53<incorrect_output reason="NEVER append multiple children at the same location.">
54{
55 "title": "Add Rectangle methods",
56 "suggestions": [
57 {
58 "kind": "AppendChild",
59 "path": "src/shapes.rs",
60 "symbol": "impl Rectangle",
61 "description": "Add calculate_area method"
62 },
63 {
64 "kind": "AppendChild",
65 "path": "src/shapes.rs",
66 "symbol": "impl Rectangle",
67 "description": "Add calculate_perimeter method"
68 }
69 ]
70}
71</incorrect_output>
72
73<correct_output>
74{
75 "title": "Add Rectangle methods",
76 "suggestions": [
77 {
78 "kind": "AppendChild",
79 "path": "src/shapes.rs",
80 "symbol": "impl Rectangle",
81 "description": "Add calculate area and perimeter methods"
82 }
83 ]
84}
85</correct_output>
86
87<step_to_resolve>
88Implement the 'Display' trait for the Rectangle struct
89</step_to_resolve>
90
91<output>
92{
93 "title": "Implement Display for Rectangle",
94 "suggestions": [
95 {
96 "kind": "InsertSiblingAfter",
97 "path": "src/shapes.rs",
98 "symbol": "impl Rectangle",
99 "description": "Implement Display trait for Rectangle"
100 }
101 ]
102}
103</output>
104
105<example>
106<workflow_context>
107<message role="user">
108```rs src/user.rs
109struct User {
110 pub name: String,
111 age: u32,
112 email: String,
113}
114
115impl User {
116 fn new(name: String, age: u32, email: String) -> Self {
117 User { name, age, email }
118 }
119
120 pub fn print_info(&self) {
121 println!("Name: {}, Age: {}, Email: {}", self.name, self.age, self.email);
122 }
123}
124```
125</message>
126<message role="assistant">
127Certainly!
128<step>Update the 'print_info' method to use formatted output</step>
129<step>Remove the 'email' field from the User struct</step>
130</message>
131</workflow_context>
132
133<step_to_resolve>
134Update the 'print_info' method to use formatted output
135</step_to_resolve>
136
137<output>
138{
139 "title": "Use formatted output",
140 "suggestions": [
141 {
142 "kind": "Update",
143 "path": "src/user.rs",
144 "symbol": "impl User pub fn print_info",
145 "description": "Use formatted output"
146 }
147 ]
148}
149</output>
150
151<step_to_resolve>
152Remove the 'email' field from the User struct
153</step_to_resolve>
154
155<output>
156{
157 "title": "Remove email field",
158 "suggestions": [
159 {
160 "kind": "Delete",
161 "path": "src/user.rs",
162 "symbol": "struct User email"
163 }
164 ]
165}
166</output>
167</example>
168
169<example>
170<workflow_context>
171<message role="user">
172```rs src/vehicle.rs
173struct Vehicle {
174 make: String,
175 model: String,
176 year: u32,
177}
178
179impl Vehicle {
180 fn new(make: String, model: String, year: u32) -> Self {
181 Vehicle { make, model, year }
182 }
183
184 fn print_year(&self) {
185 println!("Year: {}", self.year);
186 }
187}
188```
189</message>
190<message role="assistant">
191<step>Add a 'use std::fmt;' statement at the beginning of the file</step>
192<step>Add a new method 'start_engine' in the Vehicle impl block</step>
193</message>
194</workflow_context>
195
196<step_to_resolve>
197Add a 'use std::fmt;' statement at the beginning of the file
198</step_to_resolve>
199
200<output>
201{
202 "title": "Add use std::fmt statement",
203 "suggestions": [
204 {
205 "kind": "PrependChild",
206 "path": "src/vehicle.rs",
207 "symbol": "#imports",
208 "description": "Add 'use std::fmt' statement"
209 }
210 ]
211}
212</output>
213
214<step_to_resolve>
215Add a new method 'start_engine' in the Vehicle impl block
216</step_to_resolve>
217
218<output>
219{
220 "title": "Add start_engine method",
221 "suggestions": [
222 {
223 "kind": "InsertSiblingAfter",
224 "path": "src/vehicle.rs",
225 "symbol": "impl Vehicle fn new",
226 "description": "Add start_engine method"
227 }
228 ]
229}
230</output>
231</example>
232
233<example>
234<workflow_context>
235<message role="user">
236```rs src/employee.rs
237struct Employee {
238 name: String,
239 position: String,
240 salary: u32,
241 department: String,
242}
243
244impl Employee {
245 fn new(name: String, position: String, salary: u32, department: String) -> Self {
246 Employee { name, position, salary, department }
247 }
248
249 fn print_details(&self) {
250 println!("Name: {}, Position: {}, Salary: {}, Department: {}",
251 self.name, self.position, self.salary, self.department);
252 }
253
254 fn give_raise(&mut self, amount: u32) {
255 self.salary += amount;
256 }
257}
258```
259</message>
260<message role="assistant">
261<step>Make salary an f32</step>
262<step>Remove the 'department' field and update the 'print_details' method</step>
263</message>
264</workflow_context>
265
266<step_to_resolve>
267Make salary an f32
268</step_to_resolve>
269
270<incorrect_output reason="NEVER include suggestions on a parent symbol and one of its children in the same suggestions block.">
271{
272 "title": "Change salary to f32",
273 "suggestions": [
274 {
275 "kind": "Update",
276 "path": "src/employee.rs",
277 "symbol": "struct Employee",
278 "description": "Change the type of salary to an f32"
279 },
280 {
281 "kind": "Update",
282 "path": "src/employee.rs",
283 "symbol": "struct Employee salary",
284 "description": "Change the type to an f32"
285 }
286 ]
287}
288</incorrect_output>
289
290<correct_output>
291{
292 "title": "Change salary to f32",
293 "suggestions": [
294 {
295 "kind": "Update",
296 "path": "src/employee.rs",
297 "symbol": "struct Employee salary",
298 "description": "Change the type to an f32"
299 }
300 ]
301}
302</correct_output>
303
304<step_to_resolve>
305Remove the 'department' field and update the 'print_details' method
306</step_to_resolve>
307
308<output>
309{
310 "title": "Remove department",
311 "suggestions": [
312 {
313 "kind": "Delete",
314 "path": "src/employee.rs",
315 "symbol": "struct Employee department"
316 },
317 {
318 "kind": "Update",
319 "path": "src/employee.rs",
320 "symbol": "impl Employee fn print_details",
321 "description": "Don't print the 'department' field"
322 }
323 ]
324}
325</output>
326</example>
327
328<example>
329<workflow_context>
330<message role="user">
331```rs src/game.rs
332struct Player {
333 name: String,
334 health: i32,
335 pub score: u32,
336}
337
338impl Player {
339 pub fn new(name: String) -> Self {
340 Player { name, health: 100, score: 0 }
341 }
342}
343
344struct Game {
345 players: Vec<Player>,
346}
347
348impl Game {
349 fn new() -> Self {
350 Game { players: Vec::new() }
351 }
352}
353```
354</message>
355<message role="assistant">
356<step>Add a 'level' field to Player and update the 'new' method</step>
357</message>
358</workflow_context>
359
360<step_to_resolve>
361Add a 'level' field to Player and update the 'new' method
362</step_to_resolve>
363
364<output>
365{
366 "title": "Add level field to Player",
367 "suggestions": [
368 {
369 "kind": "InsertSiblingAfter",
370 "path": "src/game.rs",
371 "symbol": "struct Player pub score",
372 "description": "Add level field to Player"
373 },
374 {
375 "kind": "Update",
376 "path": "src/game.rs",
377 "symbol": "impl Player pub fn new",
378 "description": "Initialize level in new method"
379 }
380 ]
381}
382</output>
383</example>
384
385<example>
386<workflow_context>
387<message role="user">
388```rs src/config.rs
389use std::collections::HashMap;
390
391struct Config {
392 settings: HashMap<String, String>,
393}
394
395impl Config {
396 fn new() -> Self {
397 Config { settings: HashMap::new() }
398 }
399}
400```
401</message>
402<message role="assistant">
403<step>Add a 'load_from_file' method to Config and import necessary modules</step>
404</message>
405</workflow_context>
406
407<step_to_resolve>
408Add a 'load_from_file' method to Config and import necessary modules
409</step_to_resolve>
410
411<output>
412{
413 "title": "Add load_from_file method",
414 "suggestions": [
415 {
416 "kind": "PrependChild",
417 "path": "src/config.rs",
418 "symbol": "#imports",
419 "description": "Import std::fs and std::io modules"
420 },
421 {
422 "kind": "AppendChild",
423 "path": "src/config.rs",
424 "symbol": "impl Config",
425 "description": "Add load_from_file method"
426 }
427 ]
428}
429</output>
430</example>
431
432<example>
433<workflow_context>
434<message role="user">
435```rs src/database.rs
436pub(crate) struct Database {
437 connection: Connection,
438}
439
440impl Database {
441 fn new(url: &str) -> Result<Self, Error> {
442 let connection = Connection::connect(url)?;
443 Ok(Database { connection })
444 }
445
446 async fn query(&self, sql: &str) -> Result<Vec<Row>, Error> {
447 self.connection.query(sql, &[])
448 }
449}
450```
451</message>
452<message role="assistant">
453<step>Add error handling to the 'query' method and create a custom error type</step>
454</message>
455</workflow_context>
456
457<step_to_resolve>
458Add error handling to the 'query' method and create a custom error type
459</step_to_resolve>
460
461<output>
462{
463 "title": "Add error handling to query",
464 "suggestions": [
465 {
466 "kind": "PrependChild",
467 "path": "src/database.rs",
468 "description": "Import necessary error handling modules"
469 },
470 {
471 "kind": "InsertSiblingBefore",
472 "path": "src/database.rs",
473 "symbol": "pub(crate) struct Database",
474 "description": "Define custom DatabaseError enum"
475 },
476 {
477 "kind": "Update",
478 "path": "src/database.rs",
479 "symbol": "impl Database async fn query",
480 "description": "Implement error handling in query method"
481 }
482 ]
483}
484</output>
485</example>
486</examples>
487
488Now generate the suggestions for the following step:
489
490<workflow_context>
491{{{workflow_context}}}
492</workflow_context>
493
494<step_to_resolve>
495{{{step_to_resolve}}}
496</step_to_resolve>