step_resolution.hbs

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