> ## 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.

# Intent Analyzer

> IntentAnalyzer refines the idea using the user’s answers and produces refined_requirements.

## Purpose and Responsibilities

* Combine the **original idea** and **answers** to clarifying questions.
* Produce structured **refined\_requirements**: title, description, features, target\_audience, technical\_requirements.
* Output must be ready for **PlatformSelector** and **Execution**.

***

## Input/Output

### Input

* `idea: string` — From `WorkflowContext` (or fallback in request).
* `answers: string[]` — User answers to `clarifying_questions`.
* `sessionId: string` — For logging.

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

```
{
  status: "success";
  stage: "intent_analysis";
  refined_requirements: {
    title: string;
    description: string;
    features: string[];
    target_audience: string;
    technical_requirements: string[];
  };
  next_stage: "platform_selection";
}
```

***

## Prompt Engineering

* **System:** Defines the “expert requirements analyst (IntentAnalyzer)” and the **exact JSON** shape. No extra fields.
* **User:** `Session ID: ${sessionId}\nOriginal Idea: ${idea}\nUser Answers: ${answers.join("\n")}`
* **Options:** `response_format: { type: "json_object" }`, `temperature: 0.7`. Model: `DEFAULT_MODEL_TYPE`.

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

***

## Examples

### Input (conceptual)

* Idea: “A habit tracker with streaks and reminders.”
* Answers: `["Web first, mobile later", "No social", "Push and in-app reminders"]`

### Output (refined\_requirements)

```
{
  "status": "success",
  "stage": "intent_analysis",
  "refined_requirements": {
    "title": "Habit Tracker",
    "description": "Web-first habit tracker with streaks and push plus in-app reminders; mobile later.",
    "features": ["habit logging", "streaks", "push reminders", "in-app reminders"],
    "target_audience": "Individuals focusing on personal habits",
    "technical_requirements": ["Web (React/Next.js) first", "Push notifications", "Mobile in a later phase"]
  },
  "next_stage": "platform_selection"
}
```

***

## Customization Options

* **Model:** Pass `modelType` to `refineIntent`.
* **System prompt:** Adjust in `lib/openai.ts` to enforce different structure (e.g. more fields, stricter technical\_requirements).
* **Stricter parsing:** Add a schema/validator on the parsed JSON before returning.

***
