scenarios:
  - id: git-init
    title: "Initialize a Repo and Make Your First Commit"
    difficulty: beginner
    xp: 20
    setup: []
    files:
      - name: README.md
        content: "# My Project"
        language: markdown
        readonly: false
    task: "Initialize a new Git repository here, add README.md to staging, and make your first commit with message \"Initial commit\"."
    validations:
      - label: ".git directory exists"
        check: output-contains
        pattern: "Initialized empty Git repository|\.git"
      - label: "First commit made"
        check: output-contains
        pattern: "Initial commit|\[master.*\] Initial"
    hints:
      - "What command creates a new Git repository in the current directory?"
      - "You'll need to stage files before committing. What does git add do?"
      - "git init, then git add README.md, then git commit -m \"Initial commit\""
    agent_prompts:
      on_start: "Before we run any commands — what do you think happens when you initialize a Git repository? What gets created?"
      on_complete: "You've made your first commit. What's the difference between the working directory, staging area, and repository? How does git add fit in?"

  - id: branching
    title: "Create and Switch Between Branches"
    difficulty: beginner
    xp: 25
    setup:
      - "git init && git branch -M main"
      - "echo 'line 1' > notes.txt"
      - "git add notes.txt && git commit -m 'First commit'"
      - "echo 'line 2' >> notes.txt && git add notes.txt && git commit -m 'Second commit'"
    files: []
    task: "Create branch feature/notes, switch to it, add \"line 3\" to notes.txt, commit, then switch back to main. Use git branch to confirm both branches exist."
    validations:
      - label: "Feature branch created"
        check: output-contains
        pattern: "feature/notes|Switched to branch"
      - label: "Commit on feature branch"
        check: output-contains
        pattern: "line 3|Third|feature"
    hints:
      - "Git has a shortcut to create and switch in one step. What might git checkout -b do?"
      - "After making changes on the branch, commit them before switching back."
      - "git checkout -b feature/notes, edit notes.txt, git add, git commit, then git checkout main"
    agent_prompts:
      on_start: "Why might you want multiple branches? What problem does branching solve when several people work on the same project?"
      on_complete: "When you switched back to main, did notes.txt still have 'line 3'? Why or why not?"

  - id: merge-conflict
    title: "Resolve a Merge Conflict"
    difficulty: intermediate
    xp: 35
    setup:
      - "git init && git branch -M main"
      - "echo 'Hello World' > greeting.txt"
      - "git add greeting.txt && git commit -m 'Initial commit'"
      - "git checkout -b feature-a"
      - "echo 'Hello from branch A' > greeting.txt"
      - "git add greeting.txt && git commit -m \"A's version\""
      - "git checkout main"
      - "git checkout -b feature-b"
      - "echo 'Hello from branch B' > greeting.txt"
      - "git add greeting.txt && git commit -m \"B's version\""
      - "git checkout main"
      - "git merge feature-a -m 'Merge A'"
    files: []
    task: "Merge feature-b into main. Resolve the conflict in greeting.txt by editing the file, removing conflict markers, staging, and completing the merge."
    validations:
      - label: "Merge attempted"
        check: command-match
        pattern: "git merge"
      - label: "Conflict resolved"
        check: output-contains
        pattern: "Merge made|merge successful|Automatic merge"
      - label: "Merge committed"
        check: output-contains
        pattern: "Merge branch|merge commit"
    hints:
      - "Run git merge feature-b. When you see CONFLICT, open greeting.txt and look for <<<<<<<, =======, >>>>>>>."
      - "Edit the file to remove the markers and keep the content you want, then git add greeting.txt."
      - "After staging the resolved file, run git commit (Git will suggest a default merge message)."
    agent_prompts:
      on_start: "When two branches change the same line in the same file, Git can't decide automatically. What would you look for in a conflicted file to understand what each branch changed?"
      on_complete: "Could you have avoided this conflict? How might rebasing have changed the situation?"

  - id: interactive-rebase
    title: "Squash Commits with Interactive Rebase"
    difficulty: intermediate
    xp: 40
    setup:
      - "git init && git branch -M main"
      - "echo 'fix 1' > changelog.txt && git add . && git commit -m 'wip'"
      - "echo 'fix 2' >> changelog.txt && git add . && git commit -m 'typo fix'"
      - "echo 'fix 3' >> changelog.txt && git add . && git commit -m 'oops forgot'"
      - "echo 'fix 4' >> changelog.txt && git add . && git commit -m 'all done'"
    files: []
    task: "Use git rebase -i HEAD~4 to squash the 4 commits into 2. Change the second and fourth 'pick' to 'squash', save, and complete the rebase."
    validations:
      - label: "Rebase started"
        check: command-match
        pattern: "git rebase -i|git rebase --interactive"
      - label: "Commit count reduced"
        check: output-contains
        pattern: "Successfully rebased|2 commits|2 files changed"
    hints:
      - "Interactive rebase lets you edit, squash, or reorder commits. Try git rebase -i HEAD~4."
      - "In the todo list, 'pick' keeps a commit, 'squash' (or 's') combines it with the previous one."
      - "Change lines 2 and 4 from 'pick' to 'squash', save and close. Git will then prompt for new commit messages."
    agent_prompts:
      on_start: "Why might you want to squash commits before pushing? What's the trade-off between a detailed history and a clean one?"
      on_complete: "When would you avoid rebasing? Think about commits that others have already pulled."

  - id: cherry-pick
    title: "Cherry-Pick a Specific Commit Between Branches"
    difficulty: advanced
    xp: 40
    setup:
      - "git init && git branch -M main"
      - "echo 'base' > config.txt && git add . && git commit -m 'base'"
      - "git checkout -b feature"
      - "echo 'A' >> config.txt && git add . && git commit -m 'Commit A'"
      - "echo 'B' >> config.txt && git add . && git commit -m 'Commit B - the fix we need'"
      - "echo 'C' >> config.txt && git add . && git commit -m 'Commit C'"
      - "git checkout main"
    files: []
    task: "The feature branch has 3 commits (A, B, C). Cherry-pick only the middle one (Commit B) onto main. Use git log feature to find its hash."
    validations:
      - label: "Cherry-pick command used"
        check: command-match
        pattern: "git cherry-pick"
      - label: "Correct commit applied"
        check: output-contains
        pattern: "Commit B|the fix we need|cherry-pick"
    hints:
      - "git log feature --oneline will show the commit hashes. The middle one is Commit B."
      - "Cherry-pick applies a specific commit from another branch onto your current branch."
      - "git cherry-pick <hash-of-B>. Use the full hash or the short 7-character prefix."
    agent_prompts:
      on_start: "Sometimes you want one commit from a branch but not the whole branch. What Git operation would you use? How is it different from merge?"
      on_complete: "When might cherry-picking cause problems? Consider what happens if the picked commit depends on earlier commits from its branch."
