# Phase 1: Requirements Discovery

Collect user requirements and generate configuration for the manual generation process.

## Objective

Gather essential information about the software project to customize the manual generation:
- Software type and characteristics
- Target user audience
- Documentation scope and depth
- Special requirements

## Execution Steps

### Step 1: Software Information Collection

Use `AskUserQuestion` to collect:

```javascript
AskUserQuestion({
  questions: [
    {
      question: "What type of software is this project?",
      header: "Software Type",
      options: [
        { label: "Web Application", description: "Frontend + Backend web app with UI" },
        { label: "CLI Tool", description: "Command-line interface tool" },
        { label: "SDK/Library", description: "Developer library or SDK" },
        { label: "Desktop App", description: "Desktop application (Electron, etc.)" }
      ],
      multiSelect: false
    },
    {
      question: "Who is the target audience for this manual?",
      header: "Target Users",
      options: [
        { label: "End Users", description: "Non-technical users who use the product" },
        { label: "Developers", description: "Developers integrating or extending the product" },
        { label: "Administrators", description: "System admins deploying and maintaining" },
        { label: "All Audiences", description: "Mixed audience with different sections" }
      ],
      multiSelect: false
    },
    {
      question: "What documentation scope do you need?",
      header: "Doc Scope",
      options: [
        { label: "Quick Start", description: "Essential getting started guide only" },
        { label: "User Guide", description: "Complete user-facing documentation" },
        { label: "API Reference", description: "Focus on API documentation" },
        { label: "Comprehensive", description: "Full documentation including all sections" }
      ],
      multiSelect: false
    },
    {
      question: "What difficulty levels should code examples cover?",
      header: "Example Levels",
      options: [
        { label: "Beginner Only", description: "Simple, basic examples" },
        { label: "Beginner + Intermediate", description: "Basic to moderate complexity" },
        { label: "All Levels", description: "Beginner, Intermediate, and Advanced" }
      ],
      multiSelect: false
    }
  ]
});
```

### Step 2: Auto-Detection (Supplement)

Automatically detect project characteristics:

```javascript
// Detect from package.json
const packageJson = Read('package.json');
const softwareName = packageJson.name;
const version = packageJson.version;
const description = packageJson.description;

// Detect tech stack
const hasReact = packageJson.dependencies?.react;
const hasVue = packageJson.dependencies?.vue;
const hasExpress = packageJson.dependencies?.express;
const hasNestJS = packageJson.dependencies?.['@nestjs/core'];

// Detect CLI
const hasBin = !!packageJson.bin;

// Detect UI
const hasPages = Glob('src/pages/**/*').length > 0 || Glob('pages/**/*').length > 0;
const hasRoutes = Glob('**/routes.*').length > 0;
```

### Step 3: Generate Configuration

Create `manual-config.json`:

```json
{
  "software": {
    "name": "{{detected or user input}}",
    "version": "{{from package.json}}",
    "description": "{{from package.json}}",
    "type": "{{web|cli|sdk|desktop}}"
  },
  "target_audience": "{{end_users|developers|admins|all}}",
  "doc_scope": "{{quick_start|user_guide|api_reference|comprehensive}}",
  "example_levels": ["beginner", "intermediate", "advanced"],
  "tech_stack": {
    "frontend": "{{react|vue|angular|vanilla}}",
    "backend": "{{express|nestjs|fastify|none}}",
    "language": "{{typescript|javascript}}",
    "ui_framework": "{{tailwind|mui|antd|none}}"
  },
  "features": {
    "has_ui": true,
    "has_api": true,
    "has_cli": false,
    "has_config": true
  },
  "agents_to_run": [
    "overview",
    "ui-guide",
    "api-docs",
    "config",
    "troubleshooting",
    "code-examples"
  ],
  "screenshot_config": {
    "enabled": true,
    "dev_command": "npm run dev",
    "dev_url": "http://localhost:3000",
    "wait_timeout": 5000
  },
  "output": {
    "filename": "{{name}}-使用手册.html",
    "theme": "light",
    "language": "zh-CN"
  },
  "timestamp": "{{ISO8601}}"
}
```

## Agent Selection Logic

Based on `doc_scope`, select agents to run:

| Scope | Agents |
|-------|--------|
| quick_start | overview |
| user_guide | overview, ui-guide, config, troubleshooting |
| api_reference | overview, api-docs, code-examples |
| comprehensive | ALL 6 agents |

## Output

- **File**: `manual-config.json`
- **Location**: `.workflow/.scratchpad/manual-{timestamp}/`

## Next Phase

Proceed to [Phase 2: Project Exploration](02-project-exploration.md) with the generated configuration.
