Skip to content

Conversation

@wwch123
Copy link
Collaborator

@wwch123 wwch123 commented Aug 27, 2025

feat: add user requirements analysis feature in chat mode

🎯 Overview

Adds intelligent requirement gathering to chat interface - AI generates targeted questions to help users provide more detailed project requirements before code generation.

✨ Key Features

  • Guided Analysis Mode: AI asks 5-8 smart questions based on user's initial input
  • Flexible Interaction: Users can answer, skip, or provide partial responses
  • Smart Question Generation: Context-aware questions for web apps, data analysis, ML projects
  • Structured Output: AI synthesizes answers into comprehensive requirement documents

🔧 Implementation

  • New RequirementAnalysisAgent following MCP Agent architecture
  • Enhanced UI with 3-step workflow: Input → Questions → Requirements Review
  • Async processing with progress tracking
  • Robust error handling with intelligent fallbacks

🚀 User Flow

  1. Select "Guided Analysis" in chat
  2. Enter basic project idea
  3. Answer AI-generated questions
  4. Review detailed requirements
  5. Proceed to code generation

💡 Benefits

  • Better Code Quality: More detailed requirements → more accurate implementations
  • User Guidance: Helps users consider aspects they might miss
  • Reduced Iterations: Fewer clarification rounds needed
  • Backward Compatible: Existing direct input unchanged

@xbingW
Copy link

xbingW commented Sep 17, 2025

@MonkeyCode-AI review this pr plz

Copy link

@MonkeyCode-AI MonkeyCode-AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request 概述

该 PR 实现了用户需求分析功能,通过 AI 生成引导性问题帮助用户明确项目需求。主要变更包括:

  1. 新增了 RequirementAnalysisAgent 来处理需求分析
  2. 在 UI 中增加了引导分析模式和相关组件
  3. 扩展了工作流引擎以支持新的需求分析流程

文件变更说明

  • prompts/code_prompts.py: 添加了需求分析相关的提示词索引
  • prompts/requirement_analysis_prompts.py: 新增文件,包含需求分析的提示词模板
  • ui/components.py: 添加了引导分析模式的 UI 组件
  • ui/handlers.py: 增加了处理需求分析工作流的异步函数和会话状态管理
  • ui/layout.py: 修改了输入界面的渲染逻辑以支持新功能
  • workflows/agent_orchestration_engine.py: 添加了需求分析代理的执行逻辑
  • workflows/agents/requirement_analysis_agent.py: 新增文件,实现了需求分析的核心代理逻辑

该实现增强了用户与系统交互的方式,有助于生成更精确的代码实现。

- PAPER_CONCEPT_ANALYSIS_PROMPT: 专注系统架构,突出概念到代码的映射
- CODE_PLANNING_PROMPT: 整合前两者输出,生成高质量复现计划
NEW: 用户需求分析相关提示词

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议在注释中添加新提示词的具体用途和使用场景,以方便其他开发者理解和维护。

@@ -0,0 +1,71 @@
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议在模块级别添加详细的文档字符串,说明该模块包含的提示词模板及其用途。

import streamlit as st
import sys
from typing import Dict, Any, Optional
from typing import Dict, Any, Optional, List

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议添加类型注解以提高代码可读性和类型安全性。

Args:
task_counter: Task counter

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议将组件拆分为更小的函数,以提高代码可维护性和可测试性。

pass


async def handle_requirement_analysis_workflow(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议添加更多的日志记录,特别是在异常处理部分,以方便调试和问题追踪。

return {"status": "error", "message": str(e)}


async def run_requirement_analysis_agent(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现run_requirement_analysis_agent函数在此文件中重复定义。建议移除重复的定义以避免混淆。

def __init__(self, logger: Optional[logging.Logger] = None):
"""
Initialize requirement analysis agent
Args:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释中存在拼写错误,'Design Philosophy:ß' 应为 'Design Philosophy:'。

@MonkeyCode-AI
Copy link

⏳ MonkeyCode-AI 正在分析,请稍等片刻...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants