name: multi-turn-edit
description: Multi-turn conversation - add a method, then rename it

tags:
  - file-editing
  - multi-turn

setup:
  Cargo.toml: |
    [package]
    name = "user-service"
    version = "0.1.0"
    edition = "2021"

    [workspace]

  src/main.rs: |
    mod models;

    use models::user::User;

    fn main() {
        let user = User::new("Alice", "Smith");
        println!("User: {} {}", user.first_name(), user.last_name());
    }

  src/models/mod.rs: |
    pub mod user;

  src/models/user.rs: |
    pub struct User {
        first_name: String,
        last_name: String,
    }

    impl User {
        pub fn new(first_name: &str, last_name: &str) -> Self {
            Self {
                first_name: first_name.to_string(),
                last_name: last_name.to_string(),
            }
        }

        pub fn first_name(&self) -> &str {
            &self.first_name
        }

        pub fn last_name(&self) -> &str {
            &self.last_name
        }
    }

turns:
  - prompt: |
      Add an email() method to the User struct in src/models/user.rs.
      It should return a generated email in the format "first_name.last_name@example.com" (lowercase).
    validate:
      - type: file_matches
        path: src/models/user.rs
        regex: "fn\\s+email"
        name: email() added
      - type: command_succeeds
        command: "cargo build"
        name: compiles after turn 1

  - prompt: |
      Actually, can you rename the email() method to generated_email() instead?
      Make sure to update any references.
    validate:
      - type: file_matches
        path: src/models/user.rs
        regex: "fn\\s+generated_email"
        name: renamed to generated_email()
      - type: file_not_matches
        path: src/models/user.rs
        regex: "fn\\s+email\\s*\\("
        name: old email() removed
      - type: command_succeeds
        command: "cargo build"
        name: compiles after turn 2
