name: competitive_analysis
description: "Sloane researches a specific competitor, niche, or channel gap with web search and produces a competitor matrix document with CL positioning recommendation."
debug: true
model: power
system: agent_prompt

agent_prompt:
  - "= identity.md"

sections:
  - agent
  - project
  - rag
  - message
  - instructions

steps:
  - type: think
    max_tokens: 200
    output_key: search_query_1
    hint: |
      The competitor or market segment to research is described in the task message above.

      Formulate ONE precise web search query to find:
      - Direct competitors in this niche: product names, companies, pricing
      - Amazon, app store, or marketplace listings for this product type

      Output ONLY the search query. Nothing else.

  - type: tool
    capability: Tool_WebSearcher
    input_from: search_query_1
    mode: research
    max_results: 6
    fetch_pages: 3
    optional: true
    output_key: competitor_data_1

  - type: think
    max_tokens: 200
    output_key: search_query_2
    hint: |
      Your first search found competitor products and pricing.
      Now formulate ONE focused query to find:
      - How competitors position and market themselves (channels, messaging, audience)
      - Customer reviews, complaints, or unmet needs in this niche

      Output ONLY the search query. Nothing else.

  - type: tool
    capability: Tool_WebSearcher
    input_from: search_query_2
    mode: research
    max_results: 5
    fetch_pages: 2
    optional: true
    output_key: competitor_data_2

  - type: think
    max_tokens: 6000
    output_key: competitor_matrix
    hint: |
      You are Sloane, Director of Marketing & Brand Strategy at Crimson Leaf Holdings.
      Produce a competitor matrix document for the niche described in the task message.

      === COMPETITOR DATA (products / pricing) ===
      {competitor_data_1}
      === END COMPETITOR DATA ===

      === AUDIENCE / POSITIONING DATA ===
      {competitor_data_2}
      === END AUDIENCE DATA ===

      Cite every data point with [Title](URL) inline.
      If research is empty, note it and use structural analysis -- do NOT invent facts.

      Structure the document exactly as follows:

      # Competitive Analysis: [niche/topic from task message]

      ---

      ## 1. Competitor Matrix

      | Competitor | Product | Price | Audience | Strengths | Weaknesses |
      |------------|---------|-------|----------|-----------|------------|
      [Fill in 3-5 rows from research. Use real names and real prices where found.]

      ## 2. Market Gaps
      - [What none of the above competitors do well]
      - [Underserved audience segments]
      - [Channels or formats competitors ignore]

      ## 3. CL Differentiation Opportunity
      - Entry point: [specific niche CL could own]
      - Unique angle: [what would make CL's offering distinct]
      - Required capabilities: [what CL needs to execute this]

      ## 4. Recommended Positioning
      - Target customer: [specific description]
      - Core message: [one sentence value proposition]
      - Primary channel: [where to reach this audience]
      - Secondary channel: [backup channel]

      ## 5. Distribution Channels Competitors Use
      [List channels found in research: social platforms, newsletters, communities, etc.]

      ## 6. Recommendation
      PURSUE / MONITOR / PASS

      Rationale: [2-3 sentences backed by data from the analysis above]

      ---

      ## Sources
      [List all cited URLs with titles]

  - type: document
    source_step: competitor_matrix
    dest_path: "deliverables/competitive-analysis/competitive-analysis-{task.id}.md"
    commit_msg: "research: competitive analysis task={task.id}"

  - type: close
    rag_update: true

  - type: reply
    target: channel
    channel_name: "crimson_leaf:live-feed"
    hint: |
      Write a 2-3 line summary of the competitive analysis just completed.
      Include: what niche was analyzed, the recommendation (PURSUE/MONITOR/PASS),
      and the single most important gap found.
      Keep it tight and action-oriented.

adjudication:
  enabled: true
  pass_threshold: 70
  deliverable_type: analysis
  criteria:
    specificity:
      weight: 40
      description: "Named competitors with real product/price data from web search -- not vague category descriptions"
    gap_clarity:
      weight: 35
      description: "Market gaps clearly identified with evidence from research -- white space is specific and actionable"
    actionability:
      weight: 25
      description: "CL positioning recommendation is concrete and feasible given current capabilities"
