name: company_proposal
description: "Produce a complete, board-ready business plan for a proposed new Crimson Leaf subsidiary. Includes 5-source web research with inline citations and a structured bibliography."
debug: true
model: power
system: agent_prompt

agent_prompt: |
  You are Edgar Chen, CEO of Crimson Leaf Holdings. You are writing a formal business plan.

  NON-NEGOTIABLE RULES FOR THIS TASK:
  1. WRITE THE DOCUMENT. Do NOT ask for clarification. Do NOT produce "holding frames."
     Do NOT say "I need more information." You have the brief -- that is enough.
  2. USE THE TASK MESSAGE. The company name, slug, and purpose are in the task message.
     Use them EXACTLY. Do NOT rename, rebrand, or creatively reinterpret the company.
  3. CITE EVERYTHING. Every factual claim MUST have a [Title](URL) citation from the
     research data provided. No invented statistics. No uncited claims.
  4. IF RESEARCH IS EMPTY for a section, write: "No web data found for this area.
     Structural analysis: [your reasoning]" -- then continue. Never refuse.
  5. COMPLETE THE DOCUMENT. All required sections must be present. No truncation.

sections:
  - agent
  - project
  - message
  - instructions

steps:
  - type: tool
    action: git_read_file
    params:
      path: "deliverables/proposals/index.md"
    output_key: prior_proposals
    optional: true

  - type: think
    max_tokens: 150
    output_key: research_query_1
    hint: |
      The task message above describes a specific company to propose.
      Read it carefully. Extract the company type and purpose.

      Write ONE precise search query to find: market size and growth rate data
      for this type of business or capability.

      Output ONLY the search query. Nothing else. No numbering. No explanation.
      Example: "AI cost tracking software market size 2025 growth rate"

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

  - type: think
    max_tokens: 150
    output_key: research_query_2
    hint: |
      The task message describes a specific company type.
      Write ONE search query to find: revenue models, pricing benchmarks,
      and monetization strategies for this exact type of business.

      Output ONLY the search query. Nothing else.
      Example: "AI API cost management SaaS pricing models revenue"

  - type: tool
    capability: Tool_WebSearcher
    input_from: research_query_2
    mode: research
    max_results: 5
    fetch_pages: 3
    optional: true
    output_key: research_2

  - type: think
    max_tokens: 150
    output_key: research_query_3
    hint: |
      The task message describes a specific company type.
      Write ONE search query to find: existing companies and competitors
      in this space -- who already does this, their product names, and pricing.

      Output ONLY the search query. Nothing else.
      Example: "AI spending analytics platforms competitors 2025 enterprise"

  - type: tool
    capability: Tool_WebSearcher
    input_from: research_query_3
    mode: research
    max_results: 5
    fetch_pages: 3
    optional: true
    output_key: research_3

  - type: think
    max_tokens: 150
    output_key: research_query_4
    hint: |
      The task message describes a specific company type.
      Write ONE search query to find: case studies, success stories, or
      proof that this type of business can work -- examples of companies
      that built this and what outcomes they achieved.

      Output ONLY the search query. Nothing else.
      Example: "AI API cost visibility ROI case study implementation success"

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

  - type: think
    max_tokens: 150
    output_key: research_query_5
    hint: |
      The task message describes a specific company type.
      Write ONE search query to find: technology requirements, tools, or
      regulatory context that would affect building this type of company --
      what software, APIs, or compliance considerations apply.

      Output ONLY the search query. Nothing else.
      Example: "AI spend tracking tools technology stack requirements 2025"

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

  - type: think
    max_tokens: 4000
    output_key: research_synthesis
    hint: |
      You have completed 5 web searches. Compile ALL findings into a structured
      research synthesis. This will be cited throughout the business plan.

      === SEARCH 1: Market Size and Growth ===
      {research_1}
      === END SEARCH 1 ===

      === SEARCH 2: Revenue Models and Pricing ===
      {research_2}
      === END SEARCH 2 ===

      === SEARCH 3: Competitors and Existing Players ===
      {research_3}
      === END SEARCH 3 ===

      === SEARCH 4: Case Studies and Success Stories ===
      {research_4}
      === END SEARCH 4 ===

      === SEARCH 5: Technology and Regulatory Context ===
      {research_5}
      === END SEARCH 5 ===

      === PRIOR PROPOSALS (do NOT repeat these) ===
      {prior_proposals}
      === END PRIOR PROPOSALS ===

      Produce a RESEARCH SYNTHESIS with this exact structure:

      ## Research Synthesis

      ### Key Statistics
      List 5-10 specific data points found across all searches.
      Format: - [STAT]: [value] -- Source: [Title](URL)
      If a search returned nothing, note "No data found" for that category.

      ### Competitor Landscape
      List all named companies/products found in search 3.
      Format: - [Company/Product]: [what they do] | [pricing if found] | [weakness if mentioned]
      Cite each with [Title](URL).

      ### Case Studies Found
      List any success stories or ROI examples from search 4.
      If none: "No case studies found -- structural feasibility analysis follows in risk section."

      ### Technology Findings
      Key tools, APIs, or requirements from search 5.

      ### Complete Source List
      Number every URL found across all 5 searches.
      [1] [Title](URL) -- what data this source provided
      [2] [Title](URL) -- what data this source provided
      (continue for all sources)

  - type: think
    max_tokens: 3000
    output_key: exec_summary
    hint: |
      Write the EXECUTIVE SUMMARY section NOW.
      Do NOT ask for clarification. Do NOT add preambles.
      The company to propose is in the task message above -- use it EXACTLY.

      === RESEARCH SYNTHESIS ===
      {research_synthesis}
      === END ===

      1. PROPOSED COMPANY
         - Full name and slug EXACTLY from the task message
         - One-sentence purpose
         - Which gap it closes

      2. PROBLEM STATEMENT
         What can Crimson Leaf NOT do today without this company? Be specific.

      3. MARKET OPPORTUNITY
         Cite every statistic with [Title](URL) from the research synthesis.
         If no market data was found, say so and use structural analysis.

      4. PROPOSED SOLUTION
         How does this close the gap? First 30 days, first 90 days.

      5. STRATEGIC FIT
         How does this advance the primary mission (profitable AI publishing)?

  - type: think
    max_tokens: 2000
    output_key: cost_model
    hint: |
      Write the COST MODEL AND FINANCIAL PROJECTIONS section NOW.
      Cite from the research synthesis where available.

      === RESEARCH SYNTHESIS ===
      {research_synthesis}
      === END ===

      1. SETUP COSTS
         - Gitea repo creation (one-time, zero API cost)
         - Template development estimate
         - Agent configuration

      2. RECURRING OPERATIONAL COSTS
         - Tasks per week at steady state
         - Average cost per task (power model: ~$0.05-0.15 typical)
         - Weekly and monthly API cost projection

      3. COST-BENEFIT ANALYSIS
         - Cost of NOT having this company?
         - Break-even point?
         - Cite pricing benchmarks with [Title](URL) if found.

      4. BUDGET CONSTRAINT CHECK
         - Does this create a self-funding loop?

  - type: think
    max_tokens: 1500
    output_key: risk_analysis
    hint: |
      Write the RISK ANALYSIS AND ALTERNATIVES CONSIDERED section NOW.

      === RESEARCH SYNTHESIS (competitor data) ===
      {research_synthesis}
      === END ===

      1. RISKS OF PROCEEDING -- rate each: Low / Medium / High

      2. RISKS OF NOT PROCEEDING -- what gets worse? Rate each.

      3. COMPETITIVE RISK
         Use competitor data from the synthesis. Cite with [Title](URL).

      4. ALTERNATIVES CONSIDERED
         A. New template in existing company -- why rejected?
         B. One-time manual report -- why rejected?
         C. Expand existing subsidiary -- why rejected?
         D. Wait -- why rejected?

      5. RECOMMENDATION
         Proceed? State the minimum viable version.

  - type: think
    max_tokens: 2500
    output_key: company_spec
    hint: |
      Write the PROPOSED COMPANY SPECIFICATION NOW.
      Use the EXACT company name and slug from the task message.

      1. COMPANY RECORD
         company_id: TBD (David assigns)
         name: (from task message)
         slug: (from task message)
         parent_company: crimson_leaf
         mission: (one sentence)
         tagline: (one-liner)
         type: (operations/research/production/marketing)
         status: active

      2. PROPOSED AGENTS
         For each: role title, name, 2-3 sentence personality, responsibilities,
         model recommendation, supported_templates list.

      3. PROPOSED TEMPLATES (MVP set)
         For each: name, purpose, key steps, trigger, estimated cost per run.

      4. SCHEDULE -- what runs on what frequency?

      5. 90-DAY SUCCESS CRITERIA
         3-5 measurable outcomes verifiable without subjective judgment.

      6. DEPENDENCIES -- what must exist before this company can operate?

  - type: think
    max_tokens: 9000
    output_key: full_proposal
    hint: |
      Assemble the complete business plan NOW.
      Do NOT truncate any section. Do NOT add preamble notices.
      Use the company name EXACTLY from the task message.

      # Proposal: [Company Full Name from task message]
      Submitted by: Edgar Chen, CEO, Crimson Leaf Holdings
      Task ID: {task.id}
      Status: AWAITING DAVID'S APPROVAL

      ---

      ## Executive Summary
      {exec_summary}

      ---

      ## Research Sources
      (Paste the "Complete Source List" from the research synthesis)
      {research_synthesis}

      ---

      ## Cost Model and Financial Projections
      {cost_model}

      ---

      ## Risk Analysis and Alternatives Considered
      {risk_analysis}

      ---

      ## Proposed Company Specification
      {company_spec}

      ---

      ## Signature Block
      Edgar Chen certifies this proposal meets Crimson Leaf Holdings governance requirements:
      - No existing subsidiary duplicates this charter
      - No existing template or tool can solve this gap
      - No proposal for this company has been submitted in the last 30 days
      - A full business plan with 5-source web research and inline citations is provided

      This proposal requires David Baity's explicit approval before any action is taken.

      Output ONLY the document. Start with the # Proposal heading.

  - type: document
    source_step: full_proposal
    dest_path: "deliverables/proposals/proposal-{task.id}.md"
    commit_msg: "proposal: company_proposal task={task.id}"

  - type: think
    max_tokens: 3000
    output_key: index_update
    hint: |
      You just wrote a company proposal. Update the proposal index.

      Current index content:
      {prior_proposals}

      Append a new entry at the bottom of the "Submitted Proposals" section.
      Use this EXACT format (plain ASCII only -- no emojis, no Unicode):

      ### [Company Full Name] -- Task {task.id}
      Date: 2026-04-29
      Status: AWAITING DAVID'S APPROVAL
      Summary: [2-3 sentences: what was proposed, what gap it fills, how it
                differs from any prior proposals]

      Output the COMPLETE updated index file from the very beginning.
      Do not truncate. Include all prior entries plus the new one.

  - type: document
    source_step: index_update
    dest_path: "deliverables/proposals/index.md"
    commit_msg: "index: add proposal {task.id} to proposal index"

  - type: reply
    target: channel
    channel_name: "crimson_leaf:general"
    hint: |
      Write a professional 4-6 line message to David announcing the proposal is ready.
      Include:
      - Which company is proposed (name and slug from task message)
      - The core gap it addresses (one sentence)
      - One key market statistic with citation (from research synthesis if available)
      - Where to find it: pae/crimson_leaf/deliverables/proposals/
      - A clear request for approval or feedback
      Plain ASCII only. No emojis. No Unicode characters.

adjudication:
  enabled: true
  pass_threshold: 80
  deliverable_type: proposal
  criteria:
    market_research:
      weight: 30
      description: "At least 5 real web-sourced data points with [Title](URL) inline citations -- no invented statistics"
    completeness:
      weight: 25
      description: "All required sections present: exec summary, cost model, risk analysis, company spec, source list"
    specificity:
      weight: 25
      description: "Specific company name/slug from task message, concrete 90-day metrics, no vague filler"
    no_duplicates:
      weight: 20
      description: "Proposed company does not duplicate an existing subsidiary or prior proposal"
