diff --git a/pipeline_service/agent_loop.py b/pipeline_service/agent_loop.py index 75f9dbe..5cf26f0 100644 --- a/pipeline_service/agent_loop.py +++ b/pipeline_service/agent_loop.py @@ -307,9 +307,14 @@ async def _git_setup(workdir): async def _git_commit_push(workdir, commit_message, branch='main'): - """git add → commit → push(无 remote 的本地仓库仅 commit)。""" + """git add → commit → push(无 remote 的本地仓库仅 commit)。非 git 目录自动 git init。""" async with _git_lock(workdir): await _git_setup(workdir) + # 非 git 目录自动 git init(模块仓库无真实远端,本地 git init) + if not os.path.isdir(os.path.join(workdir, '.git')): + r0 = await _run_shell('git init', workdir, 10) + if r0['rc'] != 0: + return {"rc": r0['rc'], "message": f"git init 失败: {r0['stderr'][:200]}"} r1 = await _run_shell('git add -A', workdir, 10) r2 = await _run_shell(f'git diff --cached --stat', workdir, 10) if not r2.get('stdout', '').strip(): @@ -346,7 +351,7 @@ AGENT_TOOLS = [ {"name":"run_shell","description":"在工作空间中执行shell命令","params":{"command":"命令"}}, {"name":"git_clone","description":"克隆git仓库到工作空间repos/下","params":{"repo_url":"仓库URL","repo_name":"仓库目录名(可选,默认从URL推断)","branch":"分支(可选,默认main)"}}, {"name":"git_status","description":"查看git仓库状态","params":{"repo_dir":"仓库子目录(可选,默认repos下第一个)"}}, - {"name":"git_commit_push","description":"git add + commit + push(一般无需调用:git 提交由 PM 审核通过后系统统一执行)","params":{"message":"提交信息","repo_dir":"仓库子目录(可选)"}}, + {"name":"git_commit_push","description":"git add + commit + push(develop 用它提交模块仓库本地提交作为产出证据;无远程只 commit 不 push,非 git 目录自动 init)","params":{"message":"提交信息","repo_dir":"仓库子目录(可选)"}}, {"name":"ask_question","description":"向用户提问(缺少信息时使用)","params":{"question":"问题"}}, {"name":"deliver","description":"提交最终交付件(代码/文档文件已用write_file写好时调用)","params":{"deliverable_type":"交付件类型(如code_files/design_doc)","summary":"概述","result":"交付件正文","files":"JSON数组[{\"path\":\"repos/仓库/src/x.py\",\"content\":\"代码内容\"}](可选)"}}, ] diff --git a/pipeline_service/sdlc_ability.py b/pipeline_service/sdlc_ability.py index c33f4d5..9fbe110 100644 --- a/pipeline_service/sdlc_ability.py +++ b/pipeline_service/sdlc_ability.py @@ -268,7 +268,7 @@ SDL_ROLES = [ - ui-design.md: 视觉风格(配色/字体/间距)、主页面布局、用户交互模式、弹窗/表单规范 模块级设计(每个模块自包含、可复用,产出到 repos/project/modules/): - - modules/<模块名>.md: 模块功能、仓库URL(先填规划地址)、技术栈、依赖、开发顺序 + - modules/<模块名>.md: 模块功能、仓库目录(本地 git 仓库 repos/<模块名>,无真实远端)、技术栈、依赖、开发顺序 - modules/<模块名>/design.md: 该模块的数据设计(表结构DDL) + CRUD 定义 + 处理逻辑(接口) - modules/<模块名>/skill/SKILL.md: 该模块技能文档 数据、CRUD、处理逻辑、skills 都属于模块本身,不放在应用级 design——这样模块可整体复用。 @@ -288,14 +288,15 @@ SDL_ROLES = [ 准备工作: 1. read_file 读 repos/project/docs/01-design/ 下架构与 UI 设计文档 2. read_file 读 repos/project/modules/<模块名>.md 获取模块仓库 URL,读 repos/project/modules/<模块名>/design.md 获取数据设计/CRUD/处理逻辑 - 3. git_clone 克隆模块仓库到 repos/ 下 + 3. 模块仓库是本地 git 仓库 repos/<模块名>/(设计里的仓库URL是规划占位地址、无真实远端,不要 git_clone) 开发流程: 4. write_file 写代码到模块仓库目录 5. run_shell 编译/运行验证 - 6. write_file 更新 repos/project/modules/<模块名>.md 状态为已完成 - 7. write_file 写 repos/project/docs/02-develop/dev-notes.md 记录开发内容 - 8. deliver 交付,files 列出所有产出文件路径(git 提交由 PM 审核通过后系统统一执行) -PM审核: list_files/read_file 检查代码文件实际产出。""", + 6. git_commit_push 提交模块仓库代码(本地提交,无远程只 commit 不 push,非 git 目录自动 init;这是 QC 核验「实际产出」的硬证据,务必执行) + 7. write_file 更新 repos/project/modules/<模块名>.md 状态为已完成 + 8. write_file 写 repos/project/docs/02-develop/dev-notes.md 记录开发内容 + 9. deliver 交付,files 列出所有产出文件路径 +PM审核: list_files/read_file 检查代码文件实际产出 + 模块仓库本地 git log 有提交。""", next_role="agent.deploy_test", ), RoleSpec( @@ -354,8 +355,9 @@ PM审核: 检查生产部署配置完整、可一键部署、有回滚方案。" 检查维度: 1. 项目规范检查: 产出是否按 SDLC 仓库标准路径/命名/格式产出 - 2. 项目过程规范: 是否遵循各阶段流程规范(develop 是否实际产出代码文件、test 是否覆盖充分、deploy 配置是否完整) + 2. 项目过程规范: 是否遵循各阶段流程规范(develop 是否实际产出代码文件——用 list_files 列 repos/<模块>/ 下的 src/sql/tests 等真实文件、read_file 抽查内容、git log 看模块仓库本地提交;test 是否覆盖充分、deploy 配置是否完整) 3. 产出质量: 内容是否完整、可量化、可验收、无重大缺陷 +核验原则: git 提交是 develop 对模块仓库的「本地提交」(无远程推送),用 list_files/read_file 核验文件真实落盘即可,不要因「无远程推送」退回。 不合规处理: review_reject 退回重做,questions 列出具体问题清单。""", next_role="", ),