name: character_update
description: Update a character's static profile when permanent arc changes occur.
  Triggered when PASS 3 flags Permanent=YES for a character.
  Reads current character deliverable, appends arc log entry, updates changed fields,
  and updates relevant RAG files if voice or magic changed.

context:
  - character_name: ""        # Full character name
  - character_slug: ""        # Slug used in deliverable filenames (e.g. mira-vasquez)
  - chapter_ref: ""           # Chapter that triggered this (e.g. ch-05)
  - permanent_change: ""      # What permanently changed, from PASS 3 output
  - project_id: ""
  - project_slug: ""

steps:
  - type: think
    hint: |
      CHARACTER ARC UPDATE

      A permanent change occurred for {character_name} in chapter {chapter_ref}.
      Permanent change: {permanent_change}

      Your tasks:
      1. Read the RAG context for this character:
         - Look for [character-{character_slug}] -- the static profile
         - Look for [character-state] -- the current live state
         - Look for [voice-signatures] -- the voice profile (if relevant)

      2. Determine what needs updating:
         - Append to the character's ## Arc Log: "Ch {chapter_ref}: {permanent_change}"
         - If a POWER was gained or lost, update the ## Abilities section
         - If a RELATIONSHIP status changed (e.g. enemies-to-allies, death),
           update the ## Relationships section
         - If VOICE changed (new speech patterns, trauma affecting language),
           update the ## Voice Signature section AND flag voice-signatures.rag.md for update
         - If MAGIC SYSTEM affinity changed, flag magic-system.rag.md for update

      3. Write the updated full character profile:
         - Keep all existing sections
         - Only change the specific fields that changed
         - Add the arc log entry
         - Mark clearly at top: "Updated: Ch {chapter_ref} -- {permanent_change}"

      Write the COMPLETE updated character profile now.

  - type: document
    filename: "character-{character_slug}"

  - type: close
    rag_update: true

adjudication:
  enabled: false
