# User Memory
# A persistent agent that learns and remembers across all your projects
#
# Usage:
#   prose run @openprose/lib/user-memory --backend sqlite+
#
# Recommended backend: sqlite+ (for durable cross-project persistence)
#
# Modes:
#   teach: Add new knowledge
#   query: Ask questions
#   reflect: Summarize what you know about a topic
#
# The memory agent accumulates knowledge over time. Each interaction
# builds on previous ones. Use liberally—teach it your preferences,
# decisions, patterns, and lessons learned.

input mode: "Mode: teach | query | reflect"
input content: "What to teach, ask, or reflect on"

# ============================================================
# Agent
# ============================================================

agent memory:
  model: opus
  persist: user
  prompt: """
    You are the user's personal knowledge base, persisting across all projects.

    You remember:
    - Technical preferences (languages, frameworks, patterns they prefer)
    - Architectural decisions and their reasoning
    - Coding conventions and style preferences
    - Mistakes they've learned from (and what to do instead)
    - Domain knowledge they've accumulated
    - Project contexts and how they relate
    - Tools, libraries, and configurations they use
    - Opinions and strong preferences

    Principles:
    - Be concise. Store knowledge efficiently.
    - Prioritize actionable knowledge over trivia.
    - Note confidence levels when uncertain.
    - Update previous knowledge when new info contradicts it.
    - Connect related pieces of knowledge.
  """

# ============================================================
# Modes
# ============================================================

if **mode is teach**:
  output result = resume: memory
    prompt: """
      Learn and remember this:

      {content}

      Integrate with your existing knowledge. If this updates or
      contradicts something you knew before, note the change.

      Respond with a brief confirmation of what you learned.
    """

elif **mode is query**:
  output result = resume: memory
    prompt: """
      Question: {content}

      Answer from your accumulated knowledge about this user.

      If you know relevant context, share it.
      If you're uncertain, say so.
      If you don't know, say that clearly.
    """

elif **mode is reflect**:
  output result = resume: memory
    prompt: """
      Reflect on your knowledge about: {content}

      Summarize:
      - What you know about this topic
      - How confident you are
      - Gaps in your knowledge
      - What would be valuable to learn

      Be honest about the limits of what you know.
    """

else:
  throw "Unknown mode: {mode}. Use: teach, query, or reflect"
