mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
c564a4a26c
Now if you try to do Suggest Edits without a file context, you see this (and it doesn't run the query). <img width="635" alt="Screenshot 2024-10-30 at 10 51 24 AM" src="https://github.com/user-attachments/assets/a3997ba6-98a9-4bfa-81b6-1d8579c26fd7"> Release Notes: - N/A --------- Co-authored-by: Antonio <antonio@zed.dev>
206 lines
5 KiB
Handlebars
206 lines
5 KiB
Handlebars
<task_description>
|
|
|
|
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.
|
|
|
|
<guidelines>
|
|
- 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.
|
|
- Always ensure imports are added if you're referencing symbols that are not in scope.
|
|
</guidelines>
|
|
|
|
Here are some concrete examples.
|
|
|
|
<example>
|
|
<message role="user">
|
|
|
|
```rs src/shapes.rs
|
|
pub mod rectangle;
|
|
pub mod circle;
|
|
```
|
|
|
|
```rs src/shapes/rectangle.rs
|
|
pub struct Rectangle {
|
|
width: f64,
|
|
height: f64,
|
|
}
|
|
|
|
impl Rectangle {
|
|
pub fn new(width: f64, height: f64) -> Self {
|
|
Rectangle { width, height }
|
|
}
|
|
}
|
|
```
|
|
|
|
```rs src/shapes/circle.rs
|
|
pub struct Circle {
|
|
radius: f64,
|
|
}
|
|
|
|
impl Circle {
|
|
pub fn new(radius: f64) -> Self {
|
|
Circle { radius }
|
|
}
|
|
}
|
|
```
|
|
|
|
Update all shapes to store their origin as an (x, y) tuple and implement Display.
|
|
</message>
|
|
|
|
<message role="assistant">
|
|
We'll need to update both the rectangle and circle modules.
|
|
|
|
<patch>
|
|
<title>Add origins and display impls to shapes</title>
|
|
<edit>
|
|
<path>src/shapes/rectangle.rs</path>
|
|
<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>
|
|
</edit>
|
|
|
|
<edit>
|
|
<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>
|
|
</edit>
|
|
|
|
<edit>
|
|
<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>
|
|
</edit>
|
|
|
|
<edit>
|
|
<path>src/shapes/circle.rs</path>
|
|
<operation>update</operation>
|
|
<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>
|
|
</edit>
|
|
</step>
|
|
|
|
<edit>
|
|
<path>src/shapes/rectangle.rs</path>
|
|
<operation>insert_before</operation>
|
|
<old_text>
|
|
struct Rectangle {
|
|
</old_text>
|
|
<new_text>
|
|
use std::fmt;
|
|
|
|
</new_text>
|
|
</edit>
|
|
|
|
<edit>
|
|
<path>src/shapes/rectangle.rs</path>
|
|
<description>
|
|
Add a manual Display implementation for Rectangle.
|
|
Currently, this is the same as a derived Display implementation.
|
|
</description>
|
|
<operation>insert_after</operation>
|
|
<old_text>
|
|
Rectangle { width, height }
|
|
}
|
|
}
|
|
</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>
|
|
</edit>
|
|
|
|
<edit>
|
|
<path>src/shapes/circle.rs</path>
|
|
<operation>insert_before</operation>
|
|
<old_text>
|
|
struct Circle {
|
|
</old_text>
|
|
<new_text>
|
|
use std::fmt;
|
|
</new_text>
|
|
</edit>
|
|
|
|
<edit>
|
|
<path>src/shapes/circle.rs</path>
|
|
<operation>insert_after</operation>
|
|
<old_text>
|
|
Circle { radius }
|
|
}
|
|
}
|
|
</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>
|
|
</edit>
|
|
</patch>
|
|
|
|
</message>
|
|
</example>
|
|
|
|
</task_description>
|