From a84e96491deedd70ceaa99f8cded6640809cd9bc Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 6 Aug 2026 14:55:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20already-exists=20pull=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=5Fresolve=5Fworkdir=E5=AE=9E=E9=99=85=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/cockpit_chat.dspy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 0ea7bfd..e665456 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -906,17 +906,20 @@ if action == 'send_message': result = await shell_exec(cmd, workdir=workdir, timeout=120 if 'git clone' in cmd else 60) # git clone already exists → git pull if result['rc'] != 0 and 'already exists' in result.get('stderr', '') and repo_target and cmd.startswith('git clone'): - pull_dir = os.path.join(workdir, repo_target) if not os.path.isabs(repo_target) else repo_target + # 用 shell_exec 解析后的实际 workdir + from pipeline_service.init import _resolve_workdir + real_workdir = _resolve_workdir() + pull_dir = os.path.join(real_workdir, repo_target) debug(f'devops: clone already exists, pulling {pull_dir}') - result = await shell_exec(f'git -C {pull_dir} pull', workdir=workdir, timeout=60) + result = await shell_exec(f'git -C {pull_dir} pull', workdir=real_workdir, timeout=60) if result['rc'] == 0: out = result['stdout'].strip() agent_reply = f"执行成功。{'输出:' + out[:500] if out else '(无输出)'}" else: agent_reply = f"执行失败(rc={result['rc']}):{result['stderr'][:500] or result['stdout'][:500]}" - # 多步任务:如果 git clone 成功且消息中含有"技能""skill""安装",自动触发 skill_import + # 多步任务:如果 git clone/pull 成功且消息中含有"技能""skill""安装",自动扫描 if result['rc'] == 0 and repo_target and re.search(r'(技能|skill|安装技能|导入技能)', message_text): - clone_dir = os.path.join(workdir, repo_target) if not os.path.isabs(repo_target) else repo_target + clone_dir = os.path.join(_resolve_workdir(), repo_target) if os.path.isdir(clone_dir): try: import_result = await skill_import_git('', skills_dir='skills')