feat: cockpit_chat 新增 devops 意图 — git/shell 操作路由

- INTENT_PROMPT 加 devops 意图描述
- 路由处理:提取操作指令,调 shell_exec 执行,返回成功/失败
This commit is contained in:
yumoqing 2026-08-05 17:56:29 +08:00
parent 79d7c139c9
commit 85cc42cec6

View File

@ -378,6 +378,7 @@ INTENT_PROMPT = """你是一个开发产线意图分类器。分析用户输入
- query: 查询当前状态 - query: 查询当前状态
- skill_list: 列出已导入的企业开发技能(如"查看技能""有哪些skills" - skill_list: 列出已导入的企业开发技能(如"查看技能""有哪些skills"
- skill_import: 导入技能文件(如"导入技能 /path/to/skill" - skill_import: 导入技能文件(如"导入技能 /path/to/skill"
- devops: git/Shell 操作(如 git clone, git pull, 克隆仓库, 执行命令, 安装依赖)
- chat: 开发相关的一般对话 - chat: 开发相关的一般对话
- answer_question: 用户在回答角色Agent此前提出的问题见「待客户回答的问题」 - answer_question: 用户在回答角色Agent此前提出的问题见「待客户回答的问题」
- out_of_scope: 完全无关软件开发 - out_of_scope: 完全无关软件开发
@ -874,6 +875,15 @@ if action == 'send_message':
agent_reply = f"✅ {msg}" agent_reply = f"✅ {msg}"
else: else:
agent_reply = f"❌ 导入失败:{msg}" agent_reply = f"❌ 导入失败:{msg}"
elif intent_type == 'devops':
description = intent.get('description', '') or message_text
workdir = ctx.get('workspace_dir', '') or '/d/pipeline/workspaces'
result = await shell_exec(description, workdir=workdir)
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]}"
else: else:
# chat: general conversation # chat: general conversation
messages = await _build_context(sor, iteration_id or ctx['iteration_id'], '', messages = await _build_context(sor, iteration_id or ctx['iteration_id'], '',