This commit is contained in:
董宏凯 committed 2026-05-18 17:47:33 +08:00
commit 49e5aaea6b
194 files changed
+63359 -3567

No files matched your search

@@ -474,6 +474,16 @@ export const enUS: Translations = {
deleteConfirm:
"Delete skill \"{name}\"? This cannot be undone and the skill will be removed from any agent that referenced it.",
deleteSuccess: "Skill deleted",
detailSectionTitle: "Details",
detailEmpty: "No details yet.",
detailEditAction: "Edit details",
detailPlaceholder:
"Describe the skill's purpose, use cases and usage notes (Markdown supported).",
detailSaveSuccess: "Details updated",
detailAdminOnlyHint:
"Only an admin or the skill publisher can edit the details.",
contentSectionTitle: "SKILL.md source",
viewDetailAction: "View skill details",
stateSheet: {
archivedTitle: "Archived skills",
archivedDescription:
@@ -405,6 +405,14 @@ export interface Translations {
deleteAction: string;
deleteConfirm: string;
deleteSuccess: string;
detailSectionTitle: string;
detailEmpty: string;
detailEditAction: string;
detailPlaceholder: string;
detailSaveSuccess: string;
detailAdminOnlyHint: string;
contentSectionTitle: string;
viewDetailAction: string;
stateSheet: {
archivedTitle: string;
archivedDescription: string;
@@ -454,6 +454,14 @@ export const zhCN: Translations = {
deleteAction: "删除技能",
deleteConfirm: "确认删除技能 “{name}”?该操作不可恢复,且会从引用它的所有智能体中自动移除。",
deleteSuccess: "技能已删除",
detailSectionTitle: "详情",
detailEmpty: "暂无详情说明。",
detailEditAction: "编辑详情",
detailPlaceholder: "用 Markdown 补充技能的用途、适用场景、使用说明等。",
detailSaveSuccess: "详情已更新",
detailAdminOnlyHint: "仅管理员或技能发布者可编辑详情。",
contentSectionTitle: "SKILL.md 原文",
viewDetailAction: "查看技能详情",
stateSheet: {
archivedTitle: "归档的技能",
archivedDescription: "这些技能已被你或策展程序归档,可随时恢复。",
+37
View File
@@ -20,6 +20,16 @@ export async function loadSkills(params: ListSkillsParams = {}) {
return json.skills as Skill[];
}
export async function getSkill(skillName: string): Promise<Skill> {
const response = await apiFetch(
`${getBackendBaseURL()}/api/skills/${encodeURIComponent(skillName)}`,
);
if (!response.ok) {
throw await parseDetailedError(response, "Failed to load skill");
}
return response.json() as Promise<Skill>;
}
export async function enableSkill(skillName: string, enabled: boolean) {
const response = await apiFetch(
`${getBackendBaseURL()}/api/skills/${skillName}`,
@@ -212,3 +222,30 @@ export async function deleteCustomSkill(skillName: string): Promise<void> {
throw await parseDetailedError(response, "Failed to delete skill");
}
}
export interface SetSkillDetailResponse {
name: string;
detail: string | null;
}
/**
* Update a skill's long-form detail text. Owner/admin for custom skills,
* admin-only for built-in skills (backend enforces). An empty string clears it.
*/
export async function setSkillDetail(
skillName: string,
detail: string,
): Promise<SetSkillDetailResponse> {
const response = await apiFetch(
`${getBackendBaseURL()}/api/skills/${encodeURIComponent(skillName)}/detail`,
{
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ detail }),
},
);
if (!response.ok) {
throw await parseDetailedError(response, "Failed to update skill detail");
}
return response.json() as Promise<SetSkillDetailResponse>;
}
+22
View File
@@ -8,8 +8,10 @@ import {
import {
deleteCustomSkill,
enableSkill,
getSkill,
getSkillContent,
installSkillUpload,
setSkillDetail,
setSkillPinned,
setSkillPublished,
setSkillState,
@@ -38,6 +40,26 @@ export function useSkillContent(skillName: string | null) {
});
}
export function useSkill(skillName: string | null) {
return useQuery({
queryKey: ["skill", skillName],
queryFn: () => getSkill(skillName!),
enabled: !!skillName,
});
}
export function useSetSkillDetail() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ skillName, detail }: { skillName: string; detail: string }) =>
setSkillDetail(skillName, detail),
onSuccess: (_data, { skillName }) => {
void queryClient.invalidateQueries({ queryKey: ["skills"] });
void queryClient.invalidateQueries({ queryKey: ["skill", skillName] });
},
});
}
export function useEnableSkill() {
const queryClient = useQueryClient();
return useMutation({
+3
View File
@@ -14,6 +14,9 @@ export interface Skill {
owner_user_id?: string | null;
published?: boolean;
builtin?: boolean;
// Long-form detail/introduction authored by the skill owner or an admin.
// Distinct from ``description`` (parsed from SKILL.md); supports Markdown.
detail?: string | null;
// Lifecycle fields — populated by curator. The main list filters on these
// so stale / archived skills appear in dedicated drawers instead.
state?: SkillState;