feat(skills): 新增技能详情字段并统一发布图标

- 技能新增 detail 字段(skills 表新增列 + Alembic 迁移),
  由管理员或技能发布者编辑,内置/公开技能仅管理员可编辑
- 新增 PUT /api/skills/{name}/detail 接口,GET/列表接口返回 detail
- 新增可复用的技能详情弹窗组件,支持 Markdown 渲染与内联编辑
- 智能体创建/编辑选技能、智能体卡片技能徽章均可查看技能详情
- 将定时任务/智能体/技能的发布图标统一为 Globe/Lock

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
吉鑫升andClaude Opus 4.7 committed 2026-05-18 10:03:37 +08:00
1 parent 3b951efd13
commit f61d053010
17 files changed
+694 -77

No files matched your search

@@ -0,0 +1,42 @@
"""Add detail column to skills table.
Revision ID: 20260518_01
Revises: 20260515_01
Create Date: 2026-05-18
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260518_01"
down_revision = "20260515_01"
branch_labels = None
depends_on = None
def _has_table(table_name: str) -> bool:
inspector = inspect(op.get_bind())
return table_name in inspector.get_table_names()
def _has_column(table_name: str, column_name: str) -> bool:
if not _has_table(table_name):
return False
inspector = inspect(op.get_bind())
return any(col["name"] == column_name for col in inspector.get_columns(table_name))
def upgrade() -> None:
# ``skills`` may not exist yet on a brand-new DB — create_all handles that
# case with the column already present, so only patch existing tables.
if _has_table("skills") and not _has_column("skills", "detail"):
op.add_column("skills", sa.Column("detail", sa.Text(), nullable=True))
def downgrade() -> None:
if _has_column("skills", "detail"):
op.drop_column("skills", "detail")
@@ -69,6 +69,7 @@ class MemorySkillStore(SkillStore):
"name": name,
"owner_user_id": data.get("owner_user_id"),
"published": bool(data.get("published", False)),
"detail": data.get("detail"),
"created_at": _now(),
"updated_at": _now(),
}
@@ -83,6 +84,7 @@ class MemorySkillStore(SkillStore):
"name": name,
"owner_user_id": data.get("owner_user_id"),
"published": bool(data.get("published", True)),
"detail": data.get("detail"),
"created_at": _now(),
"updated_at": _now(),
}
@@ -98,6 +100,8 @@ class MemorySkillStore(SkillStore):
return None
if "published" in data:
record["published"] = bool(data["published"])
if "detail" in data:
record["detail"] = data["detail"]
record["updated_at"] = _now()
return _with_derived(_copy(record)) # type: ignore[arg-type]
@@ -109,6 +113,8 @@ class MemorySkillStore(SkillStore):
record["published"] = bool(data["published"])
if "owner_user_id" in data:
record["owner_user_id"] = data["owner_user_id"]
if "detail" in data:
record["detail"] = data["detail"]
record["updated_at"] = _now()
return _with_derived(_copy(record)) # type: ignore[arg-type]
@@ -10,7 +10,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from sqlalchemy import Boolean, DateTime, String
from sqlalchemy import Boolean, DateTime, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from deerflow.persistence.base import Base
@@ -24,5 +24,10 @@ class SkillRow(Base):
name: Mapped[str] = mapped_column(String(64), primary_key=True)
owner_user_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
published: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
# Human-authored long-form detail/introduction, editable by the skill owner
# or an admin. Distinct from the skill ``description`` parsed from SKILL.md;
# kept in the DB so admins can annotate built-in skills without rewriting
# the shared on-disk SKILL.md file.
detail: Mapped[str | None] = mapped_column(Text, nullable=True, default=None)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC))
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))
@@ -63,6 +63,7 @@ class SkillRepository(SkillStore):
name=data["name"],
owner_user_id=data.get("owner_user_id"),
published=bool(data.get("published", False)),
detail=data.get("detail"),
created_at=now,
updated_at=now,
)
@@ -81,6 +82,7 @@ class SkillRepository(SkillStore):
name=data["name"],
owner_user_id=data.get("owner_user_id"),
published=bool(data.get("published", True)),
detail=data.get("detail"),
created_at=now,
updated_at=now,
)
@@ -101,6 +103,8 @@ class SkillRepository(SkillStore):
return None
if "published" in data:
row.published = bool(data["published"])
if "detail" in data:
row.detail = data["detail"]
row.updated_at = datetime.now(UTC)
await session.commit()
await session.refresh(row)
@@ -115,6 +119,8 @@ class SkillRepository(SkillStore):
row.published = bool(data["published"])
if "owner_user_id" in data:
row.owner_user_id = data["owner_user_id"]
if "detail" in data:
row.detail = data["detail"]
row.updated_at = datetime.now(UTC)
await session.commit()
await session.refresh(row)