feat: 技能收藏与常驻(always-on)支持

- 新增 skill_favorites / skill_always_on 迁移与持久化模型字段
- skills 路由、存储、前端设置页支持收藏与常驻
- 调整摘要中间件与 lead agent 提示词
- 同步岗位 position_sync 及相关配置清理

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
吉鑫升andClaude Opus 4.8 committed 2026-06-16 16:37:43 +08:00
1 parent 5ebbb82d66
commit 5182ea5d11
19 files changed
+472 -107

No files matched your search

@@ -0,0 +1,54 @@
"""我的技能 (skill favorites) table.
New table ``skill_favorites`` — the per-user "我的技能" collection, mirroring
``agent_favorites``. A 岗位 (position) materializes its skill tag bindings into
this table (``origin='position'``) so granted skills land in the member's 我的
list while the browse-all 广场 stays complete.
Note: the running app also auto-creates this table via ``create_all`` on
startup (new tables are always created, even on existing DBs); this migration
keeps the alembic history consistent per the repo convention (see
backend/CLAUDE.md → Schema Migrations).
Revision ID: 20260616_02
Revises: 20260616_01
Create Date: 2026-06-16
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260616_02"
down_revision = "20260616_01"
branch_labels = None
depends_on = None
def _has_table(table_name: str) -> bool:
return table_name in inspect(op.get_bind()).get_table_names()
def upgrade() -> None:
if not _has_table("skill_favorites"):
op.create_table(
"skill_favorites",
sa.Column("id", sa.String(64), primary_key=True),
sa.Column("user_id", sa.String(64), nullable=False),
sa.Column("skill_name", sa.String(64), nullable=False),
sa.Column("origin", sa.String(16), nullable=False, server_default="user"),
sa.Column("position_id", sa.String(64), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.UniqueConstraint("user_id", "skill_name", name="uq_skill_favorites_user_skill"),
)
op.create_index("ix_skill_favorites_user_id", "skill_favorites", ["user_id"])
op.create_index("ix_skill_favorites_skill_name", "skill_favorites", ["skill_name"])
op.create_index("ix_skill_favorites_position_id", "skill_favorites", ["position_id"])
def downgrade() -> None:
if _has_table("skill_favorites"):
op.drop_table("skill_favorites")
@@ -0,0 +1,45 @@
"""Add always_on (常驻/免压缩) column to skills table.
Revision ID: 20260616_03
Revises: 20260616_02
Create Date: 2026-06-16
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260616_03"
down_revision = "20260616_02"
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", "always_on"):
op.add_column(
"skills",
sa.Column("always_on", sa.Boolean(), nullable=False, server_default="0"),
)
def downgrade() -> None:
if _has_column("skills", "always_on"):
op.drop_column("skills", "always_on")