step_resolution.hbs

  1Your task is to map a step from the conversation above to operations on symbols inside the provided source files.
  2
  3Guidelines:
  4- There's no need to describe *what* to do, just *where* to do it.
  5- If creating a file, assume any subsequent updates are included at the time of creation.
  6- Don't create and then update a file.
  7- We'll create it in one shot.
  8- Prefer updating symbols lower in the syntax tree if possible.
  9- Never include operations on a parent symbol and one of its children in the same operations block.
 10- Never nest an operation with another operation or include CDATA or other content. All operations are leaf nodes.
 11- Include a description attribute for each operation with a brief, one-line description of the change to perform.
 12- Descriptions are required for all operations except delete.
 13- When generating multiple operations, ensure the descriptions are specific to each individual operation.
 14- 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.
 15- Don't generate multiple operations at the same location. Instead, combine them together in a single operation with a succinct combined description.
 16
 17Example 1:
 18
 19User:
 20```rs src/rectangle.rs
 21struct Rectangle {
 22    width: f64,
 23    height: f64,
 24}
 25
 26impl Rectangle {
 27    fn new(width: f64, height: f64) -> Self {
 28        Rectangle { width, height }
 29    }
 30}
 31```
 32
 33<step>Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct</step>
 34<step>Implement the 'Display' trait for the Rectangle struct</step>
 35
 36What are the operations for the step: <step>Add a new method 'calculate_area' to the Rectangle struct</step>
 37
 38A (wrong):
 39{
 40  "title": "Add Rectangle methods",
 41  "operations": [
 42    {
 43      "kind": "AppendChild",
 44      "path": "src/shapes.rs",
 45      "symbol": "impl Rectangle",
 46      "description": "Add calculate_area method"
 47    },
 48    {
 49      "kind": "AppendChild",
 50      "path": "src/shapes.rs",
 51      "symbol": "impl Rectangle",
 52      "description": "Add calculate_perimeter method"
 53    }
 54  ]
 55}
 56
 57This demonstrates what NOT to do. NEVER append multiple children at the same location.
 58
 59A (corrected):
 60{
 61  "title": "Add Rectangle methods",
 62  "operations": [
 63    {
 64      "kind": "AppendChild",
 65      "path": "src/shapes.rs",
 66      "symbol": "impl Rectangle",
 67      "description": "Add calculate area and perimeter methods"
 68    }
 69  ]
 70}
 71
 72User:
 73What are the operations for the step: <step>Implement the 'Display' trait for the Rectangle struct</step>
 74
 75A:
 76{
 77  "title": "Implement Display for Rectangle",
 78  "operations": [
 79    {
 80      "kind": "InsertSiblingAfter",
 81      "path": "src/shapes.rs",
 82      "symbol": "impl Rectangle",
 83      "description": "Implement Display trait for Rectangle"
 84    }
 85  ]
 86}
 87
 88Example 2:
 89
 90User:
 91```rs src/user.rs
 92struct User {
 93    pub name: String,
 94    age: u32,
 95    email: String,
 96}
 97
 98impl User {
 99    fn new(name: String, age: u32, email: String) -> Self {
100        User { name, age, email }
101    }
102
103    pub fn print_info(&self) {
104        println!("Name: {}, Age: {}, Email: {}", self.name, self.age, self.email);
105    }
106}
107```
108
109<step>Update the 'print_info' method to use formatted output</step>
110<step>Remove the 'email' field from the User struct</step>
111
112What are the operations for the step: <step>Update the 'print_info' method to use formatted output</step>
113
114A:
115{
116  "title": "Use formatted output",
117  "operations": [
118    {
119      "kind": "Update",
120      "path": "src/user.rs",
121      "symbol": "impl User pub fn print_info",
122      "description": "Use formatted output"
123    }
124  ]
125}
126
127User:
128What are the operations for the step: <step>Remove the 'email' field from the User struct</step>
129
130A:
131{
132  "title": "Remove email field",
133  "operations": [
134      {
135        "kind": "Delete",
136        "path": "src/user.rs",
137        "symbol": "struct User email"
138      }
139    ]
140}
141
142Example 3:
143
144User:
145```rs src/vehicle.rs
146struct Vehicle {
147    make: String,
148    model: String,
149    year: u32,
150}
151
152impl Vehicle {
153    fn new(make: String, model: String, year: u32) -> Self {
154        Vehicle { make, model, year }
155    }
156
157    fn print_year(&self) {
158        println!("Year: {}", self.year);
159    }
160}
161```
162
163<step>Add a 'use std::fmt;' statement at the beginning of the file</step>
164<step>Add a new method 'start_engine' in the Vehicle impl block</step>
165
166What are the operations for the step: <step>Add a 'use std::fmt;' statement at the beginning of the file</step>
167
168A:
169{
170  "title": "Add use std::fmt statement",
171  "operations": [
172    {
173      "kind": "PrependChild",
174      "path": "src/vehicle.rs",
175      "description": "Add 'use std::fmt' statement"
176    }
177  ]
178}
179
180User:
181What are the operations for the step: <step>Add a new method 'start_engine' in the Vehicle impl block</step>
182
183A:
184{
185  "title": "Add start_engine method",
186  "operations": [
187    {
188      "kind": "InsertSiblingAfter",
189      "path": "src/vehicle.rs",
190      "symbol": "impl Vehicle fn new",
191      "description": "Add start_engine method"
192    }
193  ]
194}
195
196Example 4:
197
198User:
199```rs src/employee.rs
200struct Employee {
201    name: String,
202    position: String,
203    salary: u32,
204    department: String,
205}
206
207impl Employee {
208    fn new(name: String, position: String, salary: u32, department: String) -> Self {
209        Employee { name, position, salary, department }
210    }
211
212    fn print_details(&self) {
213        println!("Name: {}, Position: {}, Salary: {}, Department: {}",
214                  self.name, self.position, self.salary, self.department);
215    }
216
217    fn give_raise(&mut self, amount: u32) {
218        self.salary += amount;
219    }
220}
221```
222
223<step>Make salary an f32</step>
224
225What are the operations for the step: <step>Make salary an f32</step>
226
227A (wrong):
228{
229  "title": "Change salary to f32",
230  "operations": [
231    {
232      "kind": "Update",
233      "path": "src/employee.rs",
234      "symbol": "struct Employee",
235      "description": "Change the type of salary to an f32"
236    },
237    {
238      "kind": "Update",
239      "path": "src/employee.rs",
240      "symbol": "struct Employee salary",
241      "description": "Change the type to an f32"
242    }
243  ]
244}
245
246This example demonstrates what not to do. `struct Employee salary` is a child of `struct Employee`.
247
248A (corrected):
249{
250  "title": "Change salary to f32",
251  "operations": [
252    {
253      "kind": "Update",
254      "path": "src/employee.rs",
255      "symbol": "struct Employee salary",
256      "description": "Change the type to an f32"
257    }
258  ]
259}
260
261User:
262What are the correct operations for the step: <step>Remove the 'department' field and update the 'print_details' method</step>
263
264A:
265{
266  "title": "Remove department",
267  "operations": [
268    {
269      "kind": "Delete",
270      "path": "src/employee.rs",
271      "symbol": "struct Employee department"
272    },
273    {
274      "kind": "Update",
275      "path": "src/employee.rs",
276      "symbol": "impl Employee fn print_details",
277      "description": "Don't print the 'department' field"
278    }
279  ]
280}
281
282Example 5:
283
284User:
285```rs src/game.rs
286struct Player {
287    name: String,
288    health: i32,
289    pub score: u32,
290}
291
292impl Player {
293    pub fn new(name: String) -> Self {
294        Player { name, health: 100, score: 0 }
295    }
296}
297
298struct Game {
299    players: Vec<Player>,
300}
301
302impl Game {
303    fn new() -> Self {
304        Game { players: Vec::new() }
305    }
306}
307```
308
309<step>Add a 'level' field to Player and update the 'new' method</step>
310
311A:
312{
313  "title": "Add level field to Player",
314  "operations": [
315    {
316      "kind": "InsertSiblingAfter",
317      "path": "src/game.rs",
318      "symbol": "struct Player pub score",
319      "description": "Add level field to Player"
320    },
321    {
322      "kind": "Update",
323      "path": "src/game.rs",
324      "symbol": "impl Player pub fn new",
325      "description": "Initialize level in new method"
326    }
327  ]
328}
329
330Example 6:
331
332User:
333```rs src/config.rs
334use std::collections::HashMap;
335
336struct Config {
337    settings: HashMap<String, String>,
338}
339
340impl Config {
341    fn new() -> Self {
342        Config { settings: HashMap::new() }
343    }
344}
345```
346
347<step>Add a 'load_from_file' method to Config and import necessary modules</step>
348
349A:
350{
351  "title": "Add load_from_file method",
352  "operations": [
353    {
354      "kind": "PrependChild",
355      "path": "src/config.rs",
356      "description": "Import std::fs and std::io modules"
357    },
358    {
359      "kind": "AppendChild",
360      "path": "src/config.rs",
361      "symbol": "impl Config",
362      "description": "Add load_from_file method"
363    }
364  ]
365}
366
367Example 7:
368
369User:
370```rs src/database.rs
371pub(crate) struct Database {
372    connection: Connection,
373}
374
375impl Database {
376    fn new(url: &str) -> Result<Self, Error> {
377        let connection = Connection::connect(url)?;
378        Ok(Database { connection })
379    }
380
381    async fn query(&self, sql: &str) -> Result<Vec<Row>, Error> {
382        self.connection.query(sql, &[])
383    }
384}
385```
386
387<step>Add error handling to the 'query' method and create a custom error type</step>
388
389A:
390{
391  "title": "Add error handling to query",
392  "operations": [
393    {
394      "kind": "PrependChild",
395      "path": "src/database.rs",
396      "description": "Import necessary error handling modules"
397    },
398    {
399      "kind": "InsertSiblingBefore",
400      "path": "src/database.rs",
401      "symbol": "pub(crate) struct Database",
402      "description": "Define custom DatabaseError enum"
403    },
404    {
405      "kind": "Update",
406      "path": "src/database.rs",
407      "symbol": "impl Database async fn query",
408      "description": "Implement error handling in query method"
409    }
410  ]
411}
412
413Now generate the operations for the following step: