feat(knowledge): 项目名改 zncm + 去除元链接噪音 + 创建人显示人名
- project_name 默认 deerflow → zncm(config.yaml + 配置默认 + 模块内字面量)
- related_links() 返回空:笔记 Related 不再注入 index/_meta/taxonomy/hub 结构链接,
只保留真实相关笔记的可点 [[标题]];无相关笔记且无来源时不再渲染 ## Related 段
- 移除随之多余的项目 hub 页脚手架(index.md/_meta/taxonomy.md 仍由 obsidian 脚手架保留,可解析)
- GET /notes/{id} 用 auth provider 把 created_by/updated_by(UUID) 解析为邮箱
(created_by_name/updated_by_name),前端 footer 显示人名、解析不到才显示短 id
- 仅对新沉淀笔记生效,现有笔记不动
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
df3fac1032
commit
e7ff07debd
11 files changed
+83
-61
No files matched your search
@@ -20,7 +20,7 @@ from fastapi.responses import FileResponse
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.gateway.authz import require_auth, require_permission
|
||||
from app.gateway.deps import get_checkpointer, get_knowledge_service, get_thread_store
|
||||
from app.gateway.deps import get_checkpointer, get_knowledge_service, get_local_provider, get_thread_store
|
||||
from app.gateway.utils import sanitize_log_param
|
||||
from deerflow.knowledge.service import EmptyThreadError
|
||||
from deerflow.runtime import serialize_channel_values
|
||||
@@ -116,6 +116,31 @@ async def _read_thread_values(checkpointer, thread_id: str) -> dict[str, Any]:
|
||||
return serialize_channel_values(checkpoint.get("channel_values", {}) or {})
|
||||
|
||||
|
||||
async def _enrich_actor_names(note: dict[str, Any]) -> None:
|
||||
"""Resolve created_by/updated_by user ids to a human label (email).
|
||||
|
||||
Adds ``created_by_name`` / ``updated_by_name`` to the note dict so the UI can
|
||||
show a person instead of a raw UUID. Best-effort: unresolved ids fall back to
|
||||
``None`` and the frontend then shows a shortened id.
|
||||
"""
|
||||
provider = get_local_provider()
|
||||
cache: dict[str, str | None] = {}
|
||||
|
||||
async def name_of(uid: str | None) -> str | None:
|
||||
if not uid:
|
||||
return None
|
||||
if uid not in cache:
|
||||
try:
|
||||
user = await provider.get_user(uid)
|
||||
cache[uid] = user.email if user else None
|
||||
except Exception:
|
||||
cache[uid] = None
|
||||
return cache[uid]
|
||||
|
||||
note["created_by_name"] = await name_of(note.get("created_by"))
|
||||
note["updated_by_name"] = await name_of(note.get("updated_by"))
|
||||
|
||||
|
||||
def _messages_and_meta(values: dict[str, Any]) -> tuple[list[dict[str, Any]], str | None, list[dict[str, Any]]]:
|
||||
messages = values.get("messages")
|
||||
if not isinstance(messages, list):
|
||||
@@ -318,6 +343,7 @@ async def get_note(note_id: str, request: Request) -> dict[str, Any]:
|
||||
note = await service.get_note(note_id)
|
||||
if note is None:
|
||||
raise HTTPException(status_code=404, detail="Knowledge note not found")
|
||||
await _enrich_actor_names(note)
|
||||
return note
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user