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:
1 parent
5ebbb82d66
commit
5182ea5d11
19 files changed
+472
-107
No files matched your search
@@ -360,16 +360,24 @@ shown to users ARE the **recommended questions** (`recommended_questions` table)
|
||||
extended with `recommended_question`).
|
||||
|
||||
**Sync engine** (`deerflow/services/position_sync.py`, wired as
|
||||
`app.state.position_sync`). `PositionSyncService.resolve_visible(user, type)`
|
||||
returns `set | None` (None = unrestricted) for the **query-time** visibility
|
||||
types (`skill`, `recommended_question`). `sync_user(user)` **materializes** the
|
||||
other two into the existing "我的" tables, idempotently:
|
||||
`app.state.position_sync`). `sync_user(user)` **materializes** three resource
|
||||
types into the existing "我的" tables, idempotently:
|
||||
- agents → `agent_favorites` rows with `origin='position'`
|
||||
- **skills → `skill_favorites` rows with `origin='position'`** (table
|
||||
`SkillFavoriteRow`, migration `20260616_02`, auto-created by `create_all`)
|
||||
- scheduled tasks → `scheduled_task_subscriptions` rows with `origin='position'`
|
||||
|
||||
Skills behave **exactly like agents**: a position only *adds* its tagged skills
|
||||
to the member's 我的技能 — the browse-all 广场 is never restricted. (This replaced
|
||||
the earlier query-time visibility filter, which wrongly shrank the square to the
|
||||
bound skill.) `PositionSyncService.resolve_visible(user, type)` returns
|
||||
`set | None` (None = unrestricted) and is now used **only** for the one remaining
|
||||
query-time type, `recommended_question`.
|
||||
|
||||
Sync only ever adds/removes `origin='position'` rows, so a user's own
|
||||
favorites/subscriptions are never clobbered. Default sets: agents = built-ins
|
||||
(`user_id IS NULL`); scheduled tasks = empty; skills/questions = unrestricted.
|
||||
favorites/subscriptions are never clobbered. Default sets (no binding for a
|
||||
type): agents = built-ins (`user_id IS NULL`); skills = empty (square stays
|
||||
full, nothing added to 我的); scheduled tasks = empty; questions = unrestricted.
|
||||
`origin`/`position_id` columns were added to `agent_favorites` and
|
||||
`scheduled_task_subscriptions` — see migration `20260616_01` +
|
||||
`scripts/sql/column_additions_mysql.sql`. The running app also auto-adds these
|
||||
@@ -390,8 +398,11 @@ unassigned users inherit, else `null`); powers the top-bar 岗位 label
|
||||
(`strategy-components/Header.tsx` user cluster, via `useMyPosition`). Related
|
||||
changes: `GET /api/recommended-questions` is now
|
||||
filtered by the caller's position (`?all=1` bypasses for admin management) and
|
||||
admin can tag questions via `/api/tags/assignments/recommended_question/{id}`;
|
||||
`GET /api/skills?scope=mine` applies skill visibility. Frontend: `core/positions`
|
||||
admin can tag questions via `/api/tags/assignments/recommended_question/{id}`.
|
||||
`GET /api/skills` no longer restricts by position; each skill carries a
|
||||
`favorited` flag (true = in the caller's 我的技能, e.g. position-granted) so the
|
||||
skills page's 我的 tab includes owned ∪ position-granted skills while the 广场
|
||||
stays complete. Frontend: `core/positions`
|
||||
+ admin `PositionManagementPage` (侧边栏「综合管理 → 岗位管理」 + 右下角设置菜单).
|
||||
Recommended questions stay rendered **above** the chat input (their original
|
||||
position), just filtered by the caller's position. Tests:
|
||||
@@ -499,11 +510,18 @@ prompt body and surfaces the rest on demand via keyword retrieval.
|
||||
default 5, `keep_index_in_prompt` default true). Read/written by
|
||||
`GET`/`PUT /api/system-settings/skill-compression` (GET open to any user — the
|
||||
skill detail page reads it; PUT admin-only, refreshes the prompt cache).
|
||||
- **Per-skill 常驻 flag** — `extensions_config.json → skills.{name}.always_on`
|
||||
(`SkillStateConfig.always_on`, alongside `enabled`). Surfaced on
|
||||
`Skill.always_on` (populated in `load_skills`) and `SkillResponse.always_on`;
|
||||
toggled via `PUT /api/skills/{name}/always-on`. `update_skill` /
|
||||
`update_skill_display` preserve it when rewriting the config entry.
|
||||
- **Per-skill 常驻 flag** — stored in the **DB**: `SkillRow.always_on`
|
||||
(`Boolean`, migration `20260616_03`, idempotent SQL in
|
||||
`column_additions_mysql.sql`), **not** in `extensions_config.json` (the
|
||||
source-tree config file is read-only / unsafe to rewrite in some deployments,
|
||||
and built-in skills carry no file entry). Threaded through `SkillStore`
|
||||
create/ensure_legacy/update/update_admin + `list_always_on_names()` exactly
|
||||
like `name_zh`/`detail`; surfaced on `SkillResponse.always_on` from the
|
||||
ownership record in `_skill_to_response`. Toggled via
|
||||
`PUT /api/skills/{name}/always-on` (custom skill → owner or admin; built-in /
|
||||
public → admin only, materializes a row on demand via `ensure_legacy`). The
|
||||
prompt builder stamps `Skill.always_on` from `list_always_on_names()` via a
|
||||
sync DB bridge (`_apply_always_on` in `lead_agent/prompt.py`).
|
||||
- **Prompt split** — `get_skills_prompt_section` (`lead_agent/prompt.py`) reads
|
||||
the compression settings (skipped for restricted custom agents — they already
|
||||
have a curated allowlist). When **off**, behaviour is unchanged (all enabled
|
||||
@@ -688,7 +706,7 @@ Both endpoints are whitelisted in `auth_middleware._PUBLIC_EXACT_PATHS`. The sha
|
||||
|
||||
**`extensions_config.json`**:
|
||||
- `mcpServers` - Map of server name ? config (enabled, type, command, args, env, url, headers, oauth, description)
|
||||
- `skills` - Map of skill name ? state (enabled, always_on)
|
||||
- `skills` - Map of skill name ? state (enabled). 常驻(免压缩)/always_on lives in the `skills` DB table, not here.
|
||||
|
||||
Both can be modified at runtime via Gateway API endpoints or `DeerFlowClient` methods.
|
||||
|
||||
|
||||
Reference in new issue
Block a user