diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 1157b2c..7d77304 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -447,18 +447,56 @@ if action == 'send_message': agent_reply = "请指定迭代。「创建Sprint1」或「切换到XXX迭代」" else: title = intent.get('title', '') or message_text[:100] - task_params = {'description': intent.get('description', ''), 'input_text': message_text} + role = _guess_role(title) + # Load role-specific skills + task_skills = _load_skills(ctx.get('skills_dir', ''), role) + skills_text = _build_skills_prompt(task_skills) + task_params = { + 'description': intent.get('description', ''), + 'input_text': message_text, + 'role': role, + 'skills': skills_text, + } try: result = await pipeline_submit(org_id, 'sdlc_general', uid, title, task_params) rd = json.loads(result) if rd.get('success'): task_id = rd.get('task_id', '') await _save_context(sor, uid, pid, iid) - agent_reply = f"✅ 任务「{title}」已提交({task_id}),产线开始执行。" + # Build repo + workspace context for execution + ws = ctx.get('workspace_dir', '') + ws_root = ctx.get('workspace_root', '') + repos = ctx.get('repos', []) + repo_lines = [f"工作空间根路径:{ws_root}" if ws_root else "工作空间根路径:未配置"] + repo_lines.append(f"项目本地路径:{ws}" if ws else "项目本地路径:未配置") + if repos: + repo_lines.append("关联代码仓库:") + for rp in repos: + repo_lines.append(f" - {rp['name']}: {rp['url']} (分支:{rp['branch']}, 本地:{rp['path']})") + # Execute immediately with skills + sp = settings['system_prompt'] + if skills_text: + sp = sp + '\n\n---\n当前角色:' + role + skills_text + task_msgs = [{"role": "system", "content": sp}] + task_msgs.append({"role": "user", "content": f"请完成:{title}\n\n" + '\n'.join(repo_lines)}) + result_text = await _call_llm(model_info, task_msgs, settings['temperature']) + did = getID() + role_dir = f"{ws}/deliverables/{role}" if ws else f"deliverables/{role}" + primary_repo = repos[0]['name'] if repos else '' + await sor.C('pipeline_deliverables', { + 'id': did, 'project_id': pid, 'task_id': task_id, + 'deliverable_type': role, 'title': title, 'content': result_text, + 'repo_name': primary_repo, 'target_path': '', + 'file_path': f"{role_dir}/{task_id}.md", + 'quality_score': 80, 'review_status': 'pending', 'created_by': 'agent' + }) + await sor.sqlExe("UPDATE pipeline_tasks SET state='completed' WHERE id=${tid}$", {"tid": task_id}) + preview = result_text[:200].replace('\n', ' ') + agent_reply = f"✅ 任务「{title}」已完成(角色:{role})\n 交付件:{did}\n {preview}..." else: agent_reply = f"任务提交失败:{rd.get('message', '未知错误')}" except Exception as e: - agent_reply = f"任务提交失败:{str(e)[:200]}" + agent_reply = f"任务执行失败:{str(e)[:200]}" elif intent_type == 'add_bug': pid = ctx['project_id'] iid = ctx['iteration_id']