处理需求分析工作流(非交互式,用于命令行参数) (NEW: matching UI version)
(self, initial_idea: str)
| 49 | await self.workflow_adapter.cleanup_mcp_app() |
| 50 | |
| 51 | async def process_requirement_analysis_non_interactive(self, initial_idea: str): |
| 52 | """处理需求分析工作流(非交互式,用于命令行参数) (NEW: matching UI version)""" |
| 53 | try: |
| 54 | self.cli.print_separator() |
| 55 | self.cli.print_status( |
| 56 | "🧠 Starting requirement analysis workflow...", "info" |
| 57 | ) |
| 58 | |
| 59 | # Step 1: Generate guiding questions |
| 60 | self.cli.print_status( |
| 61 | "🤖 Generating AI-guided questions to refine your requirements...", |
| 62 | "processing", |
| 63 | ) |
| 64 | |
| 65 | questions_result = ( |
| 66 | await self.workflow_adapter.execute_requirement_analysis_workflow( |
| 67 | user_input=initial_idea, analysis_mode="generate_questions" |
| 68 | ) |
| 69 | ) |
| 70 | |
| 71 | if questions_result["status"] != "success": |
| 72 | self.cli.print_status( |
| 73 | f"❌ Failed to generate questions: {questions_result.get('error', 'Unknown error')}", |
| 74 | "error", |
| 75 | ) |
| 76 | return questions_result |
| 77 | |
| 78 | # Step 2: Display questions |
| 79 | questions_json = questions_result["result"] |
| 80 | self.cli.display_guiding_questions(questions_json) |
| 81 | |
| 82 | # For non-interactive mode, we can't get user answers, so we provide a summary |
| 83 | self.cli.print_status( |
| 84 | "ℹ️ In non-interactive mode, using initial idea for implementation", |
| 85 | "info", |
| 86 | ) |
| 87 | self.cli.print_status( |
| 88 | "💡 For guided analysis, please use interactive mode (python main_cli.py)", |
| 89 | "info", |
| 90 | ) |
| 91 | |
| 92 | # Proceed directly with the initial idea as the requirement |
| 93 | self.cli.print_status( |
| 94 | "🚀 Starting code implementation based on initial requirements...", |
| 95 | "processing", |
| 96 | ) |
| 97 | |
| 98 | implementation_result = await self.process_input(initial_idea, "chat") |
| 99 | |
| 100 | return { |
| 101 | "status": "success", |
| 102 | "questions_generated": questions_result, |
| 103 | "implementation": implementation_result, |
| 104 | } |
| 105 | |
| 106 | except Exception as e: |
| 107 | error_msg = str(e) |
| 108 | self.cli.print_error_box("Requirement Analysis Error", error_msg) |
no test coverage detected