diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 8ffd329..dc029b4 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -60,10 +60,11 @@ async def _load_context(sor, uid): ctx['iteration_id'] = getattr(r, 'current_iteration_id', '') or '' if ctx['project_id']: projs = await sor.sqlExe( - "SELECT name FROM sd_projects WHERE id=${pid}$", {"pid": ctx['project_id']} + "SELECT name, workspace_dir FROM sd_projects WHERE id=${pid}$", {"pid": ctx['project_id']} ) if projs: ctx['project_name'] = getattr(projs[0], 'name', '') + ctx['workspace_dir'] = getattr(projs[0], 'workspace_dir', '') or '' if ctx['iteration_id']: iters = await sor.sqlExe( "SELECT iteration_name FROM sd_iterations WHERE id=${iid}$", {"iid": ctx['iteration_id']} @@ -329,9 +330,11 @@ if action == 'send_message': await _save_context(sor, uid, proj.id, '') else: pid = getID() + ws_dir = f"/d/pipeline/workspaces/{org_id}/{pname}" await sor.C('sd_projects', { 'id': pid, 'name': pname, 'description': intent.get('description', ''), - 'project_type': 'software', 'org_id': org_id, 'created_by': uid, 'status': 'active' + 'project_type': 'software', 'org_id': org_id, 'created_by': uid, + 'status': 'active', 'workspace_dir': ws_dir }) # Auto-create default iteration iid = getID() @@ -405,16 +408,19 @@ if action == 'send_message': agent_reply = f"项目「{ctx['project_name']}」暂无待执行任务。\n\n请先提交开发任务,例如:设计用户表结构" else: # Execute each pending task - results = [] + ws = ctx.get('workspace_dir', '') + results = [f"📁 工作目录:{ws}" if ws else "📁 工作目录:未配置"] for t in tasks: try: task_msgs = [{"role": "system", "content": settings['system_prompt']}] - task_msgs.append({"role": "user", "content": f"请完成:{t.title}"}) + task_msgs.append({"role": "user", "content": f"请完成:{t.title}\n工作目录:{ws}"}) result = await _call_llm(model_info, task_msgs, settings['temperature']) did = getID() + role_dir = f"{ws}/deliverables/agent" await sor.C('pipeline_deliverables', { 'id': did, 'project_id': pid, 'task_id': t.id, 'deliverable_type': 'code', 'title': t.title, 'content': result, + 'file_path': f"{role_dir}/{t.id}.md", 'quality_score': 80, 'review_status': 'pending', 'created_by': 'agent' }) await sor.sqlExe("UPDATE pipeline_tasks SET state='completed' WHERE id=${tid}$", {"tid": t.id})