sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -10,7 +10,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from sqlalchemy import Boolean, DateTime, String, Text, UniqueConstraint
from sqlalchemy import BigInteger, Boolean, DateTime, Index, Integer, String, Text, UniqueConstraint, text
from sqlalchemy.orm import Mapped, mapped_column
from deerflow.persistence.base import Base
@@ -19,10 +19,30 @@ from deerflow.persistence.types import BeijingDateTime
class SkillRow(Base):
__tablename__ = "skills"
__table_args__ = (
Index("ix_skills_catalog_available_category_created", "available", "category", "created_at"),
)
# Global unique name — must match the on-disk folder name under skills/custom/.
# Hyphen-case or snake_case allowed; see deerflow.skills.validation.
name: Mapped[str] = mapped_column(String(64), primary_key=True)
# Compact catalog projection fields. The list API reads these columns from
# MySQL and deliberately excludes the long-form ``detail`` text column.
category: Mapped[str] = mapped_column(String(16), nullable=False, default="custom", server_default="custom")
description: Mapped[str] = mapped_column(String(1024), nullable=False, default="", server_default="")
license: Mapped[str | None] = mapped_column(String(255), nullable=True, default=None)
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, server_default=text("1"))
available: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, server_default=text("1"), index=True)
use_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text("0"))
view_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text("0"))
patch_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text("0"))
last_activity_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, default=None)
state: Mapped[str] = mapped_column(String(16), nullable=False, default="active", server_default="active")
pinned: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("0"))
featured: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("0"))
source: Mapped[str] = mapped_column(String(16), nullable=False, default="upload", server_default="upload")
source_mtime_ns: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0, server_default=text("0"))
detail_preview: Mapped[str | None] = mapped_column(String(1024), nullable=True, default=None)
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
@@ -83,3 +103,18 @@ class SkillDisplayAdapterRow(Base):
sample_payload: 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))
class SkillCatalogSnapshotRow(Base):
"""MySQL-backed projection of filesystem skill metadata for fast list APIs.
Skill source files remain the authoring format. The Gateway refreshes this
one-row projection during startup so homepage listing requests do not scan
every SKILL.md or read per-skill usage sidecars.
"""
__tablename__ = "skill_catalog_snapshots"
cache_key: Mapped[str] = mapped_column(String(32), primary_key=True)
catalog_json: Mapped[str] = mapped_column(Text, nullable=False)
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))