> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scriptonia.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Idea Processor

> IdeaProcessor analyzes the user’s idea and produces analysis and clarifying_questions.

## Purpose and Responsibilities

* Parse and summarize the project idea.
* Extract **key features** and estimate **complexity** (`low` | `medium` | `high`) and **estimated\_agents**.
* Generate **3–5 clarifying questions** for the Intent step.

***

## Input/Output

### Input

* `idea: string` — Raw idea from the user.
* `sessionId: string` — For logging/tracing.

### Output (`IdeaAnalysis` in `lib/openai.ts`)

```
{
  status: "success";
  stage: "idea_input";
  analysis: {
    summary: string;
    key_features: string[];
    complexity: "low" | "medium" | "high";
    estimated_agents: number;
  };
  clarifying_questions: string[];
  next_stage: "intent_analysis";
}
```

***

## Prompt Engineering

* **System:** Instructs the model to act as an “expert idea analysis assistant (IdeaProcessor)” and to respond with **valid JSON** in the exact structure above. Asks for 3–5 thoughtful clarifying questions.
* **User:** `Session ID: ${sessionId}\n\nUser Idea: ${idea}`
* **Options:** `response_format: { type: "json_object" }`, `temperature: 0.7`. Model: `DEFAULT_MODEL_TYPE` (e.g. GROK).

Implementation: `processIdea(idea, sessionId, modelType?)` in `lib/openai.ts`.

***

## Examples

### Request (via /api/idea)

```
{ "idea": "A habit tracker with streaks and reminders." }
```

### Response (idea + analysis + questions)

```
{
  "status": "success",
  "stage": "idea_input",
  "analysis": {
    "summary": "A habit tracker with streaks and reminders.",
    "key_features": ["habit logging", "streaks", "reminders"],
    "complexity": "low",
    "estimated_agents": 3
  },
  "clarifying_questions": [
    "Web, mobile, or both?",
    "Do you need social or sharing features?",
    "Should reminders be push, email, or in-app?"
  ],
  "next_stage": "intent_analysis"
}
```

***

## Customization Options

* **Model:** Pass `modelType` to `processIdea` (e.g. `QWEN`, `GEMINI`).
* **System prompt:** Edit the `processIdea` system string in `lib/openai.ts` to change tone, structure, or number of questions.
* **JSON schema:** If you change `IdeaAnalysis`, ensure the system prompt and any callers (e.g. `/api/idea`) stay in sync.

***
