PMFlow/backend/app/services/context_cache_service/mixin_profile_basics.py

135 lines
5.5 KiB
Python

from __future__ import annotations
from .shared import *
class ContextCacheProfileBasicsMixin:
@staticmethod
def _build_assistant_profile() -> dict[str, Any]:
return {
"name": "PMFlow AI 管家",
"identity": "PMFlow 内置的项目管理与技术协同助手",
"responsibilities": [
"识别需求并路由到项目/信号",
"结合结构化数据与知识库回答问题",
"辅助任务拆解、分配与优先级判断",
"输出基于证据的系统状态与风险提示",
],
"principles": [
"只基于可验证上下文回答",
"证据不足时明确说明不足字段",
"优先使用系统快照中的实时结构化数据",
],
}
@staticmethod
def _count_python_files(target: Path) -> int:
if not target.exists() or not target.is_dir():
return 0
return sum(1 for p in target.rglob("*.py") if p.is_file())
@staticmethod
def _estimate_api_routes(api_dir: Path) -> int:
if not api_dir.exists() or not api_dir.is_dir():
return 0
markers = (
"@router.get(",
"@router.post(",
"@router.put(",
"@router.patch(",
"@router.delete(",
"@router.websocket(",
)
route_count = 0
for py_file in api_dir.rglob("*.py"):
if not py_file.is_file() or py_file.name.startswith("__"):
continue
try:
text = py_file.read_text(encoding="utf-8", errors="ignore")
except Exception:
continue
for marker in markers:
route_count += text.count(marker)
return route_count
@staticmethod
def _detect_database_stack() -> str:
url = str(os.getenv("DATABASE_URL") or "").lower()
if "postgresql" in url:
return "PostgreSQL (pgvector-ready)"
if "mysql" in url:
return "MySQL"
return "Unknown"
@staticmethod
def _default_feature_catalog_items() -> list[dict[str, Any]]:
return [
{
"route": "/workloads",
"name": "团队负载",
"summary": "查看团队成员负载、瓶颈与调配建议。",
"page_component": "WorkloadsPage",
"page_file": "frontend/src/pages/WorkloadsPage.tsx",
"apis": ["/workloads/", "/workloads/ai-optimize", "/workloads/ai-optimize/apply"],
"aliases": ["workloads", "负载", "工作量", "capacity", "团队负载"],
},
{
"route": "/projects",
"name": "项目列表",
"summary": "管理项目清单、状态、入口跳转与总览信息。",
"page_component": "ProjectsPage",
"page_file": "frontend/src/pages/ProjectsPage.tsx",
"apis": ["/projects/", "/projects/?summary=1"],
"aliases": ["projects", "项目", "项目列表", "project list"],
},
{
"route": "/space",
"name": "个人空间",
"summary": "聚合项目、草案、待确认、AI 动态和问答入口。",
"page_component": "PersonalSpacePage",
"page_file": "frontend/src/pages/PersonalSpacePage.tsx",
"apis": ["/projects/?summary=1", "/pmflow-os/projects/{project_id}/truth-state", "/rag/ask", "/rag/qa-sessions", "/rag/qa-records"],
"aliases": ["space", "空间", "个人空间", "问答", "rag", "智能问答"],
},
{
"route": "/ai-config",
"name": "智能配置",
"summary": "配置飞书/企微/GitHub/知识库与模型参数,决定 AI 数据源与行为。",
"page_component": "AIConfigPage",
"page_file": "frontend/src/pages/AIConfigPage.tsx",
"apis": [
"/ai-steward/config/suggest",
"/feishu/config",
"/wecom/config",
"/rag/knowledge-base/docs",
"/rag/knowledge-base/upload",
"/rag/knowledge-base/urls",
],
"aliases": [
"智能配置",
"ai配置",
"配置中心",
"integration",
"集成配置",
"knowledge base",
],
},
{
"route": "/skills",
"name": "能力管理",
"summary": "管理能力标签、人员能力画像、任务匹配与推荐。",
"page_component": "SkillsPage",
"page_file": "frontend/src/pages/SkillsPage.tsx",
"apis": ["/skills/tags", "/skills/recommend", "/skills/users/{id}/bindings"],
"aliases": ["skills", "能力", "技能", "ability", "能力管理"],
},
{
"route": "/users",
"name": "用户管理",
"summary": "管理用户档案、角色、状态与权限入口。",
"page_component": "UsersPage",
"page_file": "frontend/src/pages/UsersPage.tsx",
"apis": ["/users/", "/users/{id}", "/users/bulk-delete", "/users/bulk-assign"],
"aliases": ["users", "成员管理", "用户", "人员管理"],
},
]