From b5892601caddc5ae9ec7db9a880f25e0b0203b8f Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 8 Aug 2026 10:36:06 +0800 Subject: [PATCH] cockpit: workspace auto-create + requirement role keyword --- wwwroot/api/cockpit_chat.dspy | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index a119e8d..7c77ec9 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -41,7 +41,8 @@ def _guess_role(title): """Guess agent role from task title keywords.""" title_lower = (title or '').lower() keywords = { - 'design': ['设计', 'design', '架构', '方案', '需求', '原型', 'ui', 'ux'], + 'requirement': ['需求分析', '需求文档', '需求规格', '需求', 'requirement', '分析需求', '调研'], + 'design': ['设计', 'design', '架构', '方案', '原型', 'ui', 'ux'], 'develop': ['开发', '编码', '实现', '编写', 'develop', 'code', 'build', '重构', '修复'], 'test': ['测试', 'test', '验证', '检查', 'review', '评审'], 'deploy': ['部署', '发布', 'deploy', 'release', '上线', '配置'], @@ -657,7 +658,19 @@ if action == 'send_message': await _save_context(sor, uid, proj.id, '') else: pid = getID() - ws_dir = f"/d/pipeline/workspaces/{org_id}/{pname}" + # 创建工作目录:检测 /d 可写性,不可写时回退 /tmp + ws_base = '/d/pipeline/workspaces' + try: + if not os.path.isdir(os.path.dirname(ws_base)) or not os.access(os.path.dirname(ws_base), os.W_OK): + ws_base = '/tmp/pipeline_workspaces' + except Exception: + ws_base = '/tmp/pipeline_workspaces' + ws_dir = f"{ws_base}/{org_id}/{pname}" + try: + os.makedirs(ws_dir, exist_ok=True) + except Exception: + ws_dir = f"/tmp/pipeline_workspaces/{pname}" + os.makedirs(ws_dir, exist_ok=True) await sor.C('sd_projects', { 'id': pid, 'name': pname, 'description': intent.get('description', ''), 'project_type': 'software', 'org_id': org_id, 'created_by': uid, @@ -670,7 +683,7 @@ if action == 'send_message': 'iteration_type': 'sprint', 'org_id': org_id, 'created_by': uid, 'status': 'active' }) await _save_context(sor, uid, pid, iid) - agent_reply = f"✅ 项目「{pname}」已创建,默认迭代已就绪。现在可以提交任务了。" + agent_reply = f"✅ 项目「{pname}」已创建(工作目录:{ws_dir}),默认迭代已就绪。现在可以提交任务了。" elif intent_type == 'select_project': pname = intent.get('project_name', '') proj = await _find_project(sor, pname, org_id)