feat(skills): 自我进化前端 — Skills 独立侧边栏 + /skills/evolution 页面
UI 重构:
- settings-dialog.tsx:把 Skills section 从设置弹窗移除
- workspace-nav-chat-list.tsx + WorkspaceRoutes.tsx + SkillsPage.tsx:
Skills 提升为独立侧边栏导航项,/workspace/skills 路由直接渲染
SkillSettingsPage(同事原型已就绪)
- skill-settings-page.tsx:顶部追加 "自我进化" 跳转按钮
自我进化页面:
- /workspace/skills/evolution 子路由 → SkillEvolutionPage 包装
- skill-evolution-panel.tsx:三段式
· 状态卡:启用/暂停徽章 + 累计运行次数 + 上次运行时间/摘要 +
技能计数 (total/active/stale/archived) + 立即执行按钮
· 配置表单:enabled / curator.enabled / interval_hours /
stale_after_days / archive_after_days / moderation_model_name
本地暂存 → 保存调 PUT,热生效
· 日志面板:拉 GET /api/curator/logs,2 秒自动刷新,monospace
展示,warning 黄、error 红
- core/curator/api.ts + hooks.ts + types.ts:TanStack Query 包装
status / config (GET/PUT) / run / logs
i18n:
- types.ts 新增 settings.skillEvolution.* 类型签名
- zh-CN.ts / en-US.ts:状态卡 / 配置表单 / 日志面板文案,
以及 settings.skills.goToEvolution
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9b6b94d919
commit
5c6ac06656
13 files changed
+826
-12
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { apiFetch } from "@/core/api";
|
||||
import { getBackendBaseURL } from "@/core/config";
|
||||
|
||||
import type {
|
||||
CuratorConfig,
|
||||
CuratorLogs,
|
||||
CuratorStatus,
|
||||
} from "./types";
|
||||
|
||||
export async function getCuratorStatus(): Promise<CuratorStatus> {
|
||||
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/status`);
|
||||
return response.json() as Promise<CuratorStatus>;
|
||||
}
|
||||
|
||||
export async function getCuratorConfig(): Promise<CuratorConfig> {
|
||||
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/config`);
|
||||
return response.json() as Promise<CuratorConfig>;
|
||||
}
|
||||
|
||||
export async function updateCuratorConfig(
|
||||
payload: CuratorConfig,
|
||||
): Promise<CuratorConfig> {
|
||||
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/config`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
return response.json() as Promise<CuratorConfig>;
|
||||
}
|
||||
|
||||
export async function runCurator(): Promise<{ triggered: boolean; message: string }> {
|
||||
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/run`, {
|
||||
method: "POST",
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getCuratorLogs(): Promise<CuratorLogs> {
|
||||
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/logs`);
|
||||
return response.json() as Promise<CuratorLogs>;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import {
|
||||
getCuratorConfig,
|
||||
getCuratorLogs,
|
||||
getCuratorStatus,
|
||||
runCurator,
|
||||
updateCuratorConfig,
|
||||
} from "./api";
|
||||
import type { CuratorConfig } from "./types";
|
||||
|
||||
const STATUS_KEY = ["curator", "status"] as const;
|
||||
const CONFIG_KEY = ["curator", "config"] as const;
|
||||
const LOGS_KEY = ["curator", "logs"] as const;
|
||||
|
||||
export function useCuratorStatus() {
|
||||
const query = useQuery({
|
||||
queryKey: STATUS_KEY,
|
||||
queryFn: getCuratorStatus,
|
||||
});
|
||||
return { status: query.data, isLoading: query.isLoading, error: query.error };
|
||||
}
|
||||
|
||||
export function useCuratorConfig() {
|
||||
const query = useQuery({
|
||||
queryKey: CONFIG_KEY,
|
||||
queryFn: getCuratorConfig,
|
||||
});
|
||||
return { config: query.data, isLoading: query.isLoading, error: query.error };
|
||||
}
|
||||
|
||||
export function useUpdateCuratorConfig() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (payload: CuratorConfig) => updateCuratorConfig(payload),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: CONFIG_KEY });
|
||||
void queryClient.invalidateQueries({ queryKey: STATUS_KEY });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useRunCurator() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: () => runCurator(),
|
||||
onSuccess: () => {
|
||||
// Logs start from scratch on a new run — refresh so the UI clears
|
||||
// immediately and then picks up the new run_started record.
|
||||
void queryClient.invalidateQueries({ queryKey: LOGS_KEY });
|
||||
void queryClient.invalidateQueries({ queryKey: STATUS_KEY });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCuratorLogs(options?: { autoRefresh?: boolean }) {
|
||||
const autoRefresh = options?.autoRefresh ?? true;
|
||||
const query = useQuery({
|
||||
queryKey: LOGS_KEY,
|
||||
queryFn: getCuratorLogs,
|
||||
refetchInterval: autoRefresh ? 2000 : false,
|
||||
});
|
||||
return {
|
||||
logs: query.data,
|
||||
isLoading: query.isLoading,
|
||||
error: query.error,
|
||||
refetch: query.refetch,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
export interface CuratorSubConfig {
|
||||
enabled: boolean;
|
||||
interval_hours: number;
|
||||
stale_after_days: number;
|
||||
archive_after_days: number;
|
||||
}
|
||||
|
||||
export interface CuratorConfig {
|
||||
enabled: boolean;
|
||||
moderation_model_name: string | null;
|
||||
curator: CuratorSubConfig;
|
||||
}
|
||||
|
||||
export interface CuratorStatus {
|
||||
enabled: boolean;
|
||||
run_count: number;
|
||||
last_run_at: string | null;
|
||||
last_run_summary: string | null;
|
||||
paused: boolean;
|
||||
agent_created_skills: {
|
||||
total: number;
|
||||
active: number;
|
||||
stale: number;
|
||||
archived: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CuratorLogRecord {
|
||||
ts: string;
|
||||
level: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface CuratorLogs {
|
||||
records: CuratorLogRecord[];
|
||||
run_count: number;
|
||||
last_run_at: string | null;
|
||||
}
|
||||
@@ -434,6 +434,7 @@ export const enUS: Translations = {
|
||||
"Manage the configuration and enabled status of the agent skills.",
|
||||
createSkill: "Create skill",
|
||||
installSkill: "Install skill",
|
||||
goToEvolution: "Skill evolution",
|
||||
emptyTitle: "No agent skill yet",
|
||||
emptyDescription:
|
||||
"Put your agent skill folders under the `/skills/custom` folder under the root folder of CM Assistant.",
|
||||
@@ -461,6 +462,65 @@ export const enUS: Translations = {
|
||||
rejectInvalidExt: "Only .zip or .skill files are accepted.",
|
||||
},
|
||||
},
|
||||
skillEvolution: {
|
||||
title: "Skill Evolution",
|
||||
description:
|
||||
"Manage the skill curator: let the agent age out, archive, and consolidate its self-created skills in the background.",
|
||||
backToSkills: "Back to skills",
|
||||
status: {
|
||||
title: "Status",
|
||||
enabled: "Enabled",
|
||||
disabled: "Disabled",
|
||||
paused: "Paused",
|
||||
runCount: "Total runs",
|
||||
runCountUnit: "",
|
||||
lastRunAt: "Last run",
|
||||
lastRunNever: "Never",
|
||||
lastRunSummary: "Last summary",
|
||||
lastRunSummaryEmpty: "—",
|
||||
skillCounts: "Skills",
|
||||
active: "Active",
|
||||
stale: "Stale",
|
||||
archived: "Archived",
|
||||
total: "Total",
|
||||
runNow: "Run now",
|
||||
runStarted: "Background run started",
|
||||
},
|
||||
config: {
|
||||
title: "Configuration",
|
||||
description:
|
||||
"Saves to skill_evolution.json and hot-reloads — no restart required.",
|
||||
enabledLabel: "Enable skill evolution",
|
||||
enabledHelper:
|
||||
"When off, the agent cannot create or modify skills under custom/.",
|
||||
curatorEnabledLabel: "Curator runs automatically",
|
||||
curatorEnabledHelper:
|
||||
"When off, the curator only runs when triggered from this page.",
|
||||
intervalHoursLabel: "Run interval (hours)",
|
||||
intervalHoursHelper:
|
||||
"Minimum hours between automatic curator runs.",
|
||||
staleAfterDaysLabel: "Stale threshold (days)",
|
||||
staleAfterDaysHelper:
|
||||
"Skills inactive for this many days are flagged stale.",
|
||||
archiveAfterDaysLabel: "Archive threshold (days)",
|
||||
archiveAfterDaysHelper:
|
||||
"Stale skills inactive for this many additional days are archived.",
|
||||
moderationModelLabel: "Moderation model (optional)",
|
||||
moderationModelHelper:
|
||||
"Leave blank to use the default chat model.",
|
||||
save: "Save changes",
|
||||
saveSuccess: "Configuration updated",
|
||||
reset: "Reset",
|
||||
},
|
||||
logs: {
|
||||
title: "Recent run logs",
|
||||
description:
|
||||
"Latest curator run only; cleared on backend restart.",
|
||||
empty: "No logs yet. Clicking 'Run now' will populate this panel.",
|
||||
autoRefresh: "Auto-refresh (2s)",
|
||||
refresh: "Refresh now",
|
||||
},
|
||||
},
|
||||
notification: {
|
||||
title: "Notification",
|
||||
description:
|
||||
|
||||
@@ -355,6 +355,7 @@ export interface Translations {
|
||||
description: string;
|
||||
createSkill: string;
|
||||
installSkill: string;
|
||||
goToEvolution: string;
|
||||
emptyTitle: string;
|
||||
emptyDescription: string;
|
||||
emptyButton: string;
|
||||
@@ -379,6 +380,56 @@ export interface Translations {
|
||||
rejectInvalidExt: string;
|
||||
};
|
||||
};
|
||||
skillEvolution: {
|
||||
title: string;
|
||||
description: string;
|
||||
backToSkills: string;
|
||||
status: {
|
||||
title: string;
|
||||
enabled: string;
|
||||
disabled: string;
|
||||
paused: string;
|
||||
runCount: string;
|
||||
runCountUnit: string;
|
||||
lastRunAt: string;
|
||||
lastRunNever: string;
|
||||
lastRunSummary: string;
|
||||
lastRunSummaryEmpty: string;
|
||||
skillCounts: string;
|
||||
active: string;
|
||||
stale: string;
|
||||
archived: string;
|
||||
total: string;
|
||||
runNow: string;
|
||||
runStarted: string;
|
||||
};
|
||||
config: {
|
||||
title: string;
|
||||
description: string;
|
||||
enabledLabel: string;
|
||||
enabledHelper: string;
|
||||
curatorEnabledLabel: string;
|
||||
curatorEnabledHelper: string;
|
||||
intervalHoursLabel: string;
|
||||
intervalHoursHelper: string;
|
||||
staleAfterDaysLabel: string;
|
||||
staleAfterDaysHelper: string;
|
||||
archiveAfterDaysLabel: string;
|
||||
archiveAfterDaysHelper: string;
|
||||
moderationModelLabel: string;
|
||||
moderationModelHelper: string;
|
||||
save: string;
|
||||
saveSuccess: string;
|
||||
reset: string;
|
||||
};
|
||||
logs: {
|
||||
title: string;
|
||||
description: string;
|
||||
empty: string;
|
||||
autoRefresh: string;
|
||||
refresh: string;
|
||||
};
|
||||
};
|
||||
notification: {
|
||||
title: string;
|
||||
description: string;
|
||||
|
||||
@@ -415,6 +415,7 @@ export const zhCN: Translations = {
|
||||
description: "管理 Agent Skill 配置和启用状态。",
|
||||
createSkill: "新建技能",
|
||||
installSkill: "安装技能",
|
||||
goToEvolution: "自我进化",
|
||||
emptyTitle: "还没有技能",
|
||||
emptyDescription:
|
||||
"将你的 Agent Skill 文件夹放在 CM 助手 根目录下的 `/skills/custom` 文件夹中。",
|
||||
@@ -441,6 +442,58 @@ export const zhCN: Translations = {
|
||||
rejectInvalidExt: "只接受 .zip 或 .skill 文件。",
|
||||
},
|
||||
},
|
||||
skillEvolution: {
|
||||
title: "自我进化",
|
||||
description:
|
||||
"管理技能 curator:让 agent 在后台对自创建的技能做老化标记、归档和合并建议。",
|
||||
backToSkills: "返回技能",
|
||||
status: {
|
||||
title: "当前状态",
|
||||
enabled: "已启用",
|
||||
disabled: "已停用",
|
||||
paused: "已暂停",
|
||||
runCount: "累计运行",
|
||||
runCountUnit: "次",
|
||||
lastRunAt: "上次运行",
|
||||
lastRunNever: "尚未运行",
|
||||
lastRunSummary: "上次摘要",
|
||||
lastRunSummaryEmpty: "—",
|
||||
skillCounts: "技能",
|
||||
active: "活跃",
|
||||
stale: "陈旧",
|
||||
archived: "已归档",
|
||||
total: "合计",
|
||||
runNow: "立即执行",
|
||||
runStarted: "已触发后台执行",
|
||||
},
|
||||
config: {
|
||||
title: "配置",
|
||||
description:
|
||||
"保存后会写入 skill_evolution.json 并热更新,无需重启。",
|
||||
enabledLabel: "启用自我进化",
|
||||
enabledHelper: "关闭后 agent 不会创建或修改 custom/ 下的技能。",
|
||||
curatorEnabledLabel: "curator 自动运行",
|
||||
curatorEnabledHelper: "关闭后只能在此页面手动触发。",
|
||||
intervalHoursLabel: "运行间隔(小时)",
|
||||
intervalHoursHelper: "两次自动运行之间至少经过的小时数。",
|
||||
staleAfterDaysLabel: "陈旧阈值(天)",
|
||||
staleAfterDaysHelper: "技能长时间不活跃后被标记为陈旧。",
|
||||
archiveAfterDaysLabel: "归档阈值(天)",
|
||||
archiveAfterDaysHelper: "标记陈旧后再经过这么多天会被自动归档。",
|
||||
moderationModelLabel: "安全审核模型(可选)",
|
||||
moderationModelHelper: "为空时使用默认主模型。",
|
||||
save: "保存修改",
|
||||
saveSuccess: "配置已更新",
|
||||
reset: "重置",
|
||||
},
|
||||
logs: {
|
||||
title: "最近运行日志",
|
||||
description: "展示最近一次 curator 运行的日志,服务重启会清空。",
|
||||
empty: "暂无日志。点击「立即执行」会写入新的运行记录。",
|
||||
autoRefresh: "自动刷新 (2s)",
|
||||
refresh: "立即刷新",
|
||||
},
|
||||
},
|
||||
notification: {
|
||||
title: "通知",
|
||||
description:
|
||||
|
||||
Reference in new issue
Block a user