Taiga integration
This commit is contained in:
@@ -67,9 +67,63 @@ def format_pomodoro_notice(tool_name: str, raw_result: str) -> str | None:
|
||||
if tool_name == "get_pomodoro_history":
|
||||
return _format_history_notice(data)
|
||||
|
||||
if tool_name == "create_work_item":
|
||||
return _format_work_item_notice(data)
|
||||
|
||||
if tool_name == "list_work_items":
|
||||
return _format_work_items_list_notice(data)
|
||||
|
||||
if tool_name == "sync_taiga_projects":
|
||||
return f"📋 Синхронизировано проектов Taiga: **{len(data)}**"
|
||||
|
||||
if tool_name == "list_taiga_projects":
|
||||
if not isinstance(data, list) or not data:
|
||||
return "📋 Проекты Taiga не найдены. Вызовите sync_taiga_projects."
|
||||
lines = ["📋 **Проекты:**"]
|
||||
for p in data:
|
||||
gitea = f"{p.get('gitea_owner')}/{p.get('gitea_repo')}" if p.get("gitea_configured") else "—"
|
||||
lines.append(f"- `{p.get('slug')}`: {p.get('name')} · Gitea: {gitea}")
|
||||
return "\n".join(lines)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def _format_work_item_notice(data: dict[str, Any]) -> str | None:
|
||||
if data.get("error"):
|
||||
return f"📋 {data['error']}"
|
||||
if not data.get("ok"):
|
||||
return None
|
||||
taiga = data.get("taiga", {})
|
||||
gitea = data.get("gitea", {})
|
||||
lines = [
|
||||
"📋 **Создано:**",
|
||||
f"- Taiga: #{taiga.get('ref')} — {taiga.get('subject')}",
|
||||
f"- URL: {taiga.get('url')}",
|
||||
]
|
||||
if gitea.get("url"):
|
||||
lines.append(f"- Gitea: {gitea.get('url')}")
|
||||
if data.get("branch"):
|
||||
lines.append(f"- Ветка: `{data['branch']}`")
|
||||
subtasks = data.get("subtasks") or []
|
||||
if subtasks:
|
||||
lines.append("**Подзадачи:**")
|
||||
for t in subtasks:
|
||||
lines.append(f"- #{t.get('ref')} {t.get('subject')}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _format_work_items_list_notice(data: Any) -> str | None:
|
||||
if not isinstance(data, list) or not data:
|
||||
return "📋 Work items не найдены."
|
||||
lines = ["📋 **Work items:**"]
|
||||
for item in data[:15]:
|
||||
lines.append(
|
||||
f"- [{item.get('status')}] #{item.get('taiga_ref')} {item.get('title')} "
|
||||
f"({item.get('taiga_slug')})"
|
||||
)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _format_status_notice(data: dict[str, Any]) -> str:
|
||||
status = data.get("status", "idle")
|
||||
phase = data.get("phase", PHASE_WORK)
|
||||
|
||||
Reference in New Issue
Block a user