2024-08-29 17:18:52 +00:00
|
|
|
<task_description>
|
2024-08-14 22:18:41 +00:00
|
|
|
|
2024-10-17 17:18:13 +00:00
|
|
|
The user of a code editor wants to make a change to their codebase.
|
|
|
|
You must describe the change using the following XML structure:
|
|
|
|
|
|
|
|
- <patch> - A group of related code changes.
|
|
|
|
Child tags:
|
|
|
|
- <title> (required) - A high-level description of the changes. This should be as short
|
|
|
|
as possible, possibly using common abbreviations.
|
|
|
|
- <edit> (1 or more) - An edit to make at a particular range within a file.
|
|
|
|
Includes the following child tags:
|
|
|
|
- <path> (required) - The path to the file that will be changed.
|
|
|
|
- <description> (optional) - An arbitrarily-long comment that describes the purpose
|
|
|
|
of this edit.
|
|
|
|
- <old_text> (optional) - An excerpt from the file's current contents that uniquely
|
|
|
|
identifies a range within the file where the edit should occur. If this tag is not
|
|
|
|
specified, then the entire file will be used as the range.
|
|
|
|
- <new_text> (required) - The new text to insert into the file.
|
|
|
|
- <operation> (required) - The type of change that should occur at the given range
|
|
|
|
of the file. Must be one of the following values:
|
|
|
|
- `update`: Replaces the entire range with the new text.
|
|
|
|
- `insert_before`: Inserts the new text before the range.
|
|
|
|
- `insert_after`: Inserts new text after the range.
|
|
|
|
- `create`: Creates a new file with the given path and the new text.
|
|
|
|
- `delete`: Deletes the specified range from the file.
|
2024-08-29 17:18:52 +00:00
|
|
|
|
|
|
|
<guidelines>
|
2024-10-17 17:18:13 +00:00
|
|
|
- Never provide multiple edits whose ranges intersect each other. Instead, merge them into one edit.
|
|
|
|
- Prefer multiple edits to smaller, disjoint ranges, rather than one edit to a larger range.
|
|
|
|
- There's no need to escape angle brackets within XML tags.
|
2024-09-03 01:20:05 +00:00
|
|
|
- Always ensure imports are added if you're referencing symbols that are not in scope.
|
2024-08-29 17:18:52 +00:00
|
|
|
</guidelines>
|
|
|
|
|
|
|
|
Here are some concrete examples.
|
|
|
|
|
2024-09-03 01:20:05 +00:00
|
|
|
<example>
|
2024-08-29 17:18:52 +00:00
|
|
|
<message role="user">
|
2024-09-03 01:20:05 +00:00
|
|
|
|
|
|
|
```rs src/shapes.rs
|
|
|
|
pub mod rectangle;
|
|
|
|
pub mod circle;
|
|
|
|
```
|
|
|
|
|
|
|
|
```rs src/shapes/rectangle.rs
|
|
|
|
pub struct Rectangle {
|
2024-08-29 17:18:52 +00:00
|
|
|
width: f64,
|
|
|
|
height: f64,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Rectangle {
|
2024-09-03 01:20:05 +00:00
|
|
|
pub fn new(width: f64, height: f64) -> Self {
|
2024-08-29 17:18:52 +00:00
|
|
|
Rectangle { width, height }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-09-03 01:20:05 +00:00
|
|
|
```rs src/shapes/circle.rs
|
|
|
|
pub struct Circle {
|
|
|
|
radius: f64,
|
2024-08-29 17:18:52 +00:00
|
|
|
}
|
|
|
|
|
2024-09-03 01:20:05 +00:00
|
|
|
impl Circle {
|
|
|
|
pub fn new(radius: f64) -> Self {
|
|
|
|
Circle { radius }
|
2024-08-01 13:56:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2024-08-29 17:18:52 +00:00
|
|
|
|
2024-09-03 01:20:05 +00:00
|
|
|
Update all shapes to store their origin as an (x, y) tuple and implement Display.
|
2024-08-29 17:18:52 +00:00
|
|
|
</message>
|
2024-08-01 13:56:17 +00:00
|
|
|
|
2024-09-03 01:20:05 +00:00
|
|
|
<message role="assistant">
|
|
|
|
We'll need to update both the rectangle and circle modules.
|
2024-08-29 17:18:52 +00:00
|
|
|
|
2024-10-17 17:18:13 +00:00
|
|
|
<patch>
|
|
|
|
<title>Add origins and display impls to shapes</title>
|
2024-08-29 17:18:52 +00:00
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/rectangle.rs</path>
|
2024-10-17 17:18:13 +00:00
|
|
|
<description>Add the origin field to Rectangle struct</description>
|
|
|
|
<operation>insert_after</operation>
|
|
|
|
<old_text>
|
|
|
|
pub struct Rectangle {
|
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
origin: (f64, f64),
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
2024-08-01 13:56:17 +00:00
|
|
|
|
2024-08-29 17:18:52 +00:00
|
|
|
<edit>
|
2024-10-17 17:18:13 +00:00
|
|
|
<path>src/shapes/rectangle.rs</path>
|
|
|
|
<operation>update</operation>
|
|
|
|
<old_text>
|
|
|
|
fn new(width: f64, height: f64) -> Self {
|
|
|
|
Rectangle { width, height }
|
|
|
|
}
|
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
fn new(origin: (f64, f64), width: f64, height: f64) -> Self {
|
|
|
|
Rectangle { origin, width, height }
|
|
|
|
}
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
2024-08-14 22:18:41 +00:00
|
|
|
|
2024-08-29 17:18:52 +00:00
|
|
|
<edit>
|
2024-10-17 17:18:13 +00:00
|
|
|
<path>src/shapes/circle.rs</path>
|
|
|
|
<description>Add the origin field to Circle struct</description>
|
|
|
|
<operation>insert_after</operation>
|
|
|
|
<old_text>
|
|
|
|
pub struct Circle {
|
|
|
|
radius: f64,
|
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
origin: (f64, f64),
|
|
|
|
</new_text>
|
2024-09-03 01:20:05 +00:00
|
|
|
</edit>
|
2024-08-29 17:18:52 +00:00
|
|
|
|
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/circle.rs</path>
|
|
|
|
<operation>update</operation>
|
2024-10-17 17:18:13 +00:00
|
|
|
<old_text>
|
|
|
|
fn new(radius: f64) -> Self {
|
|
|
|
Circle { radius }
|
|
|
|
}
|
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
fn new(origin: (f64, f64), radius: f64) -> Self {
|
|
|
|
Circle { origin, radius }
|
|
|
|
}
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
|
|
|
</step>
|
|
|
|
|
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/rectangle.rs</path>
|
|
|
|
<operation>insert_before</operation>
|
2024-10-17 17:18:13 +00:00
|
|
|
<old_text>
|
2024-09-03 01:20:05 +00:00
|
|
|
struct Rectangle {
|
2024-10-17 17:18:13 +00:00
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
|
|
|
|
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/rectangle.rs</path>
|
2024-10-25 21:30:34 +00:00
|
|
|
<description>
|
|
|
|
Add a manual Display implementation for Rectangle.
|
|
|
|
Currently, this is the same as a derived Display implementation.
|
|
|
|
</description>
|
2024-09-03 01:20:05 +00:00
|
|
|
<operation>insert_after</operation>
|
2024-10-17 17:18:13 +00:00
|
|
|
<old_text>
|
2024-09-03 01:20:05 +00:00
|
|
|
Rectangle { width, height }
|
2024-08-29 17:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-17 17:18:13 +00:00
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
impl fmt::Display for Rectangle {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.format_struct(f, "Rectangle")
|
|
|
|
.field("origin", &self.origin)
|
|
|
|
.field("width", &self.width)
|
|
|
|
.field("height", &self.height)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
|
|
|
|
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/circle.rs</path>
|
|
|
|
<operation>insert_before</operation>
|
2024-10-17 17:18:13 +00:00
|
|
|
<old_text>
|
2024-09-03 01:20:05 +00:00
|
|
|
struct Circle {
|
2024-10-17 17:18:13 +00:00
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
use std::fmt;
|
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
|
|
|
|
|
|
|
<edit>
|
2024-09-03 01:20:05 +00:00
|
|
|
<path>src/shapes/circle.rs</path>
|
|
|
|
<operation>insert_after</operation>
|
2024-10-17 17:18:13 +00:00
|
|
|
<old_text>
|
2024-09-03 01:20:05 +00:00
|
|
|
Circle { radius }
|
2024-08-29 17:18:52 +00:00
|
|
|
}
|
2024-08-14 22:18:41 +00:00
|
|
|
}
|
2024-10-17 17:18:13 +00:00
|
|
|
</old_text>
|
|
|
|
<new_text>
|
|
|
|
impl fmt::Display for Rectangle {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.format_struct(f, "Rectangle")
|
|
|
|
.field("origin", &self.origin)
|
|
|
|
.field("width", &self.width)
|
|
|
|
.field("height", &self.height)
|
|
|
|
.finish()
|
2024-08-14 22:18:41 +00:00
|
|
|
}
|
2024-08-01 13:56:17 +00:00
|
|
|
}
|
2024-10-17 17:18:13 +00:00
|
|
|
</new_text>
|
2024-08-29 17:18:52 +00:00
|
|
|
</edit>
|
2024-10-17 17:18:13 +00:00
|
|
|
</patch>
|
2024-08-29 17:18:52 +00:00
|
|
|
|
|
|
|
</message>
|
2024-08-14 22:18:41 +00:00
|
|
|
</example>
|
2024-08-29 17:18:52 +00:00
|
|
|
|
|
|
|
</task_description>
|