Files
16gagent/docs/project-intake-agent.md
2026-06-06 10:40:48 +08:00

7.4 KiB

Project Intake & PRD Agent

SF-01 — Automated Requirement-to-PRD Pipeline

Overview

The Project Intake Agent converts a one-sentence requirement into a structured PRD suitable for downstream consumption by other agents (design, development, testing).

It uses a domain-knowledge-driven approach: keyword matching against a curated domain base (12 domains), platform detection, and feature-aware template assembly.

Quick Start

# Direct text input
node scripts/project-intake-agent.mjs --input "做一个宠物管理 App" --pretty

# From file
node scripts/project-intake-agent.mjs --input-file test/fixtures/project-intake/pet-management.json --pretty

# Output to file
node scripts/project-intake-agent.mjs --input "做一个电商小程序" --output prd-output.json

Architecture

                 ┌─────────────────────────────┐
  One-Sentence   │   Project Intake Agent       │
  Requirement ──▶│                              │
                 │  1. Input Parser             │
                 │     - Platform detection     │
                 │     - Feature extraction      │
                 │     - Constraint hints        │
                 │                              │
                 │  2. Domain Matcher           │
                 │     - 12 domain KB            │
                 │     - Keyword match scoring   │
                 │     - Fallback to generic     │
                 │                              │
                 │  3. PRD Generator             │
                 │     - Persona templates       │
                 │     - Feature catalog         │
                 │     - Page blueprint          │
                 │     - API design              │
                 │     - User story assembly     │
                 │                              │
                 │  4. Task Decomposer           │
                 │     - Foundation phase        │
                 │     - UI + Backend tasks       │
                 │     - Integration + Testing    │
                 │     - Hour estimation          │
                 │                              │
                 └──────────┬──────────────────┘
                            ▼
                 ┌─────────────────────────────┐
                 │   Structured PRD (JSON)      │
                 │  - projectName, summary      │
                 │  - personas, userStories     │
                 │  - features (P0/P1/P2)       │
                 │  - pages (with routes)       │
                 │  - apiRequirements           │
                 │  - mvpScope + estimatedWeeks │
                 │  - techConstraints           │
                 │  - devTasks (with hours)     │
                 └─────────────────────────────┘

Supported Domains

Domain Key Triggers (examples)
🐱 宠物管理 pet 宠物, 猫, 狗, 动物, 领养
🛒 电商平台 ecommerce 电商, 商城, 购物, 订单, 小程序
📚 在线教育 education 教育, 课程, 学习, 培训, 题库
🏢 企业OA enterprise 企业, OA, 审批, 考勤, 部门
💪 健身打卡 fitness 健身, 运动, 打卡, 跑步, 训练
📝 笔记应用 note 笔记, 备忘录, 日记, 写作
👥 社交平台 social 社交, 社区, 朋友圈, 动态
🍔 美食应用 food 外卖, 点餐, 美食, 餐厅
✈️ 旅游应用 travel 旅游, 旅行, 酒店, 攻略
🔧 通用 generic 未匹配时降级

PRD Output Schema

{
  "projectName": "PetCare",
  "chineseName": "宠物管理",
  "domain": "pet",
  "matchConfidence": "high",
  "summary": "一款帮助宠物主人管理...",
  "personas": [
    {
      "name": "宠物主人",
      "description": "...",
      "painPoints": ["...", "..."]
    }
  ],
  "userStories": [
    {
      "id": "US-001",
      "as": "宠物主人",
      "want": "记录宠物的基本信息、品种、年龄、体重",
      "soThat": "解决痛点:忘记打疫苗时间",
      "priority": "P0"
    }
  ],
  "mvpScope": {
    "description": "MVP 聚焦 宠物档案、健康日程...",
    "features": ["宠物档案", "健康日程", "..."],
    "pages": ["首页", "宠物档案", "..."],
    "estimatedWeeks": 3
  },
  "features": [
    { "name": "宠物档案", "description": "...", "priority": "P0" }
  ],
  "pages": [
    { "name": "首页", "route": "/home", "description": "..." }
  ],
  "apiRequirements": [
    { "method": "POST", "path": "/api/pets", "description": "添加宠物档案" }
  ],
  "techConstraints": {
    "platforms": ["mobile", "web"],
    "recommendedStack": "React Native / Flutter(跨平台)",
    "considerations": ["...", "..."]
  },
  "extraFeatures": ["wechat-pay", "logistics-tracking"],
  "devTasks": [
    {
      "id": "T-001",
      "title": "项目脚手架搭建",
      "description": "...",
      "phase": "Foundation",
      "estimatedHours": 8,
      "priority": "P0"
    }
  ],
  "meta": {
    "generatedAt": "2026-06-05T00:00:00.000Z",
    "inputLength": 10,
    "domainMatchCount": 2
  }
}

Feature Detection

The agent automatically detects special requirements from keywords:

Keyword Flag Effect
微信支付 wechat-pay Adds payment API, compliance notes
支付宝 alipay Adds alipay integration notes
物流/快递 logistics-tracking Adds logistics API endpoints
推送/通知 push-notification Adds push service integration
AI/智能 ai-powered Adds AI service dependency note
离线 offline-mode Adds offline sync strategy
多语言/国际化 i18n Adds i18n integration note
实时 real-time Adds WebSocket recommendation
iOS/Android/小程序/Web Platform flags Determines recommended stack

Platform Detection

Input Detected Platforms
(no mention) mobile, web
iOS ios
安卓/Android android
小程序 miniapp, wechat-miniapp
Web/网页 web
桌面/PC desktop

Downstream Integration

The structured PRD JSON is designed for consumption by:

  • SF-02 (Architecture Agent): Reads features, apiRequirements, techConstraints → produces architecture
  • SF-03 (Design Agent): Reads pages, personas → produces UI wireframes
  • SF-04 (Dev Agent): Reads devTasks → scaffolds project
  • SF-05 (QA Agent): Reads userStories, features → generates test cases

Test Coverage

58 tests across 15 suites:

Suite Tests
1 — 宠物管理 App 4
2 — 电商小程序 5
3 — 在线教育平台 3
4 — 企业 OA 系统 5
5 — 极简输入 2
6 — 健身打卡 + 平台偏好 4
7 — 空输入与错误处理 3
8 — 通用领域降级 2
9 — PRD 结构完整性 7
10 — 任务拆解 5
11 — File I/O 3
12 — 领域匹配引擎 3
13 — 平台检测 3
14 — 额外特性检测 4
15 — CLI 端到端 5

Run with:

node --test test/project-intake-agent.test.mjs