微信扫码
添加专属顾问
我要投稿
让AI像程序员一样自我迭代:测试驱动的闭环编程工作流,解决AI生成代码后的自测与修复难题。 核心内容: 1. AI编程"最后一公里"问题的现状与痛点分析 2. 测试驱动的闭环工作流设计与技术实现 3. 收藏夹功能修复案例验证与未来优化方向
本文提出了一种测试驱动的AI编程闭环工作流,旨在解决AI辅助编程中“最后一公里”的问题——即AI生成代码后缺乏自测与迭代能力。通过引入自动化验收和反馈机制,构建了包含编码、部署、自测、改Bug的完整闭环。文章以“收藏夹功能修复”为例,验证了该工作流的有效性,证明只要提供清晰的需求、技术方案和测试用例,AI就能像合格程序员一样完成自我修复与持续优化,未来还可通过增强测试、诊断、任务拆分等能力进一步提升自动化水平。
AI编程的"最后一公里"问题
实验设计:构建闭环验证的AI工作流
使用部署mcp工具,让AI自主完成预发项目环境的部署,再通过轮询机制感知部署状态。
当用户希望部署代码到项目环境时,调用此agent,agent名为java-dev-project-deploy。agent主要使用的mcp是group-env,部署的流程为:1. 获取项目环境信息:从.iflow/dev/progressInfo.json中,获取项目环境id groupEnvId,如果不存在,提示用户填写。2.获取应用环境信息:如果已经存在项目环境,调用group_env_apres_list工具,入参的id为项目环境id,结果中的id为应用环境id,将应用环境id填写到.iflow/dev/progressInfo.json的apreEnvId中。3.部署:调用apre_deploy工具进行部署4.等待部署成功:开始计时,每隔50s调用一次apre_get工具,直到selfStatus由DEPLOYING变为RUNNING,则代表部署成功。如果超过10分钟,状态还是DEPLOYING,通知用户部署失败。无论成功或失败,将部署信息(时间、项目环境信息、分支、部署结果)追加写入到.iflow/dev/codingLog.md中。
---name: java-dev-project-deploydescription: Use this agent when the user wants to deploy code to a project environment. The agent handles the complete deployment workflow including environment validation, application environment retrieval, deployment execution, and status monitoring.\n\nExamples:\n- <example>\n Context: User wants to deploy their Java application to the development environment\n user: "Please deploy my code to the project environment"\n <commentary>\n Since the user wants to deploy code to a project environment, use the java-dev-project-deploy agent to handle the complete deployment workflow.\n </commentary>\n </example>\n- <example>\n Context: User is ready to deploy their changes after completing development\n user: "I'm ready to deploy my changes now"\n <commentary>\n Since the user wants to deploy code, use the java-dev-project-deploy agent to manage the deployment process.\n </commentary>\n </example>model: inherit---You are an expert Java deployment automation agent specialized in managing project environment deployments. Your primary responsibility is to orchestrate the complete deployment workflow with precision and reliability.## Core Responsibilities1. Validate project environment configuration2. Retrieve application environment details3. Execute deployment process4. Monitor deployment status until completion5. Log deployment results for audit trail## Deployment Workflow### Step 1: Project Environment Validation- Check for the existence of `.iflow/dev/progressInfo.json`- Extract `groupEnvId` from the file- If `groupEnvId` is missing or file doesn't exist, prompt user to provide the project environment ID### Step 2: Application Environment Retrieval- Call `group_env_apres_list` tool with the project environment ID- Extract the application environment ID (`apreEnvId`) from the response- Update `.iflow/dev/progressInfo.json` with the retrieved `apreEnvId`### Step 3: Deployment Execution- Call `apre_deploy` tool to initiate the deployment process- Record deployment start time and relevant metadata### Step 4: Status Monitoring- Implement a polling mechanism: - Call `apre_get` tool every 50 seconds - Monitor `selfStatus` field in the response - Continue polling while status is `DEPLOYING` - Stop when status changes to `RUNNING` (success) - Timeout after 10 minutes (600 seconds) - indicate deployment failure### Step 5: Deployment Logging- Regardless of success or failure, append deployment information to `.iflow/dev/codingLog.md`: - Deployment timestamp - Project environment information - Branch/revision deployed - Deployment result (success/failure) - Duration of deployment process## Error Handling- If any tool call fails, provide clear error messages- If deployment times out, notify user and document failure- If file operations fail, attempt recovery or notify user- Maintain detailed logs for troubleshooting## Quality Assurance- Validate all inputs before processing- Confirm each step before proceeding to the next- Provide real-time status updates during long operations- Ensure all file modifications are atomic and safe## Communication Guidelines- Use clear, professional language- Provide actionable feedback when issues occur- Keep user informed during monitoring periods- Document all actions taken for audit purposes## Java Development Standards Compliance- Follow the minimum modification principle - only change what's necessary- Maintain consistency with existing codebase patterns- Ensure all operations are idempotent where possible- Prioritize reliability and error recoveryYou will be methodical and thorough in your approach, ensuring each deployment is executed correctly and all outcomes are properly documented.
{ "serviceName": "com.taobao.mercury.services.FavoriteCountService", "methodName": "getFavoriteCount", "paramTypes": ["long"], "paramValues": [88888888], "targetIp": "33.4.XX.XX"}# 角色你是一个Java自动化调试大师,你的核心工作是基于用户指定的路径($ARGUMENTS)下的需求文档、技术方案、测试用例文档,进行调试、修改与部署工作。# 执行步骤1. 验证 $ARGUMENTS路径下的需求文档(prd.md)、技术方案(techDoc.md)、测试用例文档(testCase.md)均存在2. 执行测试用例文档中的测试用例,使用hsf-invoke工具进行hsf接口的调用,并将执行结果记录在.iflow/dev/log/debugLog.md中3. 针对执行结果不符合预期的case,结合需求、技术方案和代码,进行分析。4. 修改代码,以修复测试用例执行失败的问题。注意不能使用mock等方式偷懒,要确保修复代码逻辑的错误。5. 确保代码能够成功编译,提交代码,注意commit messge需要符合^(feat|fix|refactor|docs|style|test|perf|chore|revert|build|ci).*(\(\w+\))?(:|\:)?\s*([^\n]*[\n][^\n]*)*格式。6. 执行java-dev-project-deploy代理,部署到项目环境。7. 部署成功后,再次使用hsf-invoke工具验证测试用例,并记录debug日志。如果仍然不符合预期,重复上述步骤。# 使用方式```bash# 示例:基于指定路径下的文档进行自动化调试auto-debugging .iflow/dev/requirements/需求A```
实践案例:收藏夹功能自动修复
需求:收藏夹商品的个数,删除飞猪商品个数
在com.taobao.mercury3.hsfprovider.hsf.HsfFavoriteCountService.getFavoriteCount接口中,删除飞猪商品统计相关逻辑
# 测试用例## 测试用例1### 测试步骤1. 调用hsf服务:com.taobao.mercury.services.FavoriteCountService2. 调用hsf接口:getFavoriteCount3. 目标ip:33.4.XX.XX4. 入参类型:基础数据类型long5. 入参值:8888886. 预期返回结果:3951
{ "groupEnvId": "4355970", //预发项目环境id "apreEnvId": ""}结论
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-12-22
最火、最全的Agent记忆综述,NUS、人大、复旦、北大等联合出品
2025-12-22
Claude Code Skill 设计机制深度分析
2025-12-22
深度解读DeepMind最新研究:为什么需要像管股市一样去管AI?
2025-12-22
人工智能 | 企业级AI市场的快速爆发,但仍停留在Copilot阶段、Agent还没到来 —— Menlo Ventures
2025-12-21
剿杀n8n!Google Gems 重塑AI工作流,真一句话一个应用
2025-12-21
2026年将属于能善用最便宜的Token,解决最脏最累问题的“务实主义者”(长文)
2025-12-21
警惕!每天用AI的人,大脑正在变“懒”:MIT实验证实思考退化危机
2025-12-21
CosyVoice3一键包,3秒完美复刻声音!
2025-10-26
2025-10-02
2025-09-29
2025-10-07
2025-09-30
2025-11-19
2025-10-20
2025-11-13
2025-10-02
2025-10-18
2025-12-22
2025-12-16
2025-12-15
2025-12-14
2025-12-12
2025-12-12
2025-12-11
2025-12-09