feat(10-01): add skillRegistry API client and query keys
- Create ui/src/api/skillRegistry.ts with typed methods for all 7 endpoints - Use two-segment URL paths (/sourceId/slug) for Express 5 compatibility - Add skillRegistry namespace to queryKeys.ts (list/detail/versions)
This commit is contained in:
parent
4f6f85bb5a
commit
bf0a61a9db
2 changed files with 51 additions and 0 deletions
46
ui/src/api/skillRegistry.ts
Normal file
46
ui/src/api/skillRegistry.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { api } from "./client";
|
||||||
|
|
||||||
|
export type SkillListItem = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
sourceId: string;
|
||||||
|
category: string | null;
|
||||||
|
activeVersionId: string | null;
|
||||||
|
removedAt: number | null;
|
||||||
|
averageRating: number | null;
|
||||||
|
ratingCount: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SkillVersion = {
|
||||||
|
id: string;
|
||||||
|
skillId: string;
|
||||||
|
version: string;
|
||||||
|
fetchedAt: number;
|
||||||
|
cacheDir: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function skillPath(skillId: string): string {
|
||||||
|
const [sourceId, ...slugParts] = skillId.split("/");
|
||||||
|
const slug = slugParts.join("/");
|
||||||
|
return `/skill-registry/skills/${sourceId}/${slug}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const skillRegistryApi = {
|
||||||
|
list: (opts?: { includeRemoved?: boolean }) =>
|
||||||
|
api.get<SkillListItem[]>(
|
||||||
|
`/skill-registry/skills${opts?.includeRemoved ? "?includeRemoved=true" : ""}`,
|
||||||
|
),
|
||||||
|
getById: (skillId: string) =>
|
||||||
|
api.get<SkillListItem>(skillPath(skillId)),
|
||||||
|
getVersions: (skillId: string) =>
|
||||||
|
api.get<SkillVersion[]>(`${skillPath(skillId)}/versions`),
|
||||||
|
fetch: () =>
|
||||||
|
api.post<{ fetched: number; errors: string[] }>("/skill-registry/fetch", {}),
|
||||||
|
install: (skillId: string, agentSkillsDir: string) =>
|
||||||
|
api.post(`${skillPath(skillId)}/install`, { agentSkillsDir }),
|
||||||
|
rollback: (skillId: string, versionId: string, agentSkillsDir: string) =>
|
||||||
|
api.post(`${skillPath(skillId)}/rollback`, { versionId, agentSkillsDir }),
|
||||||
|
remove: (skillId: string) =>
|
||||||
|
api.delete(skillPath(skillId)),
|
||||||
|
};
|
||||||
|
|
@ -134,6 +134,11 @@ export const queryKeys = {
|
||||||
skills: {
|
skills: {
|
||||||
available: ["skills", "available"] as const,
|
available: ["skills", "available"] as const,
|
||||||
},
|
},
|
||||||
|
skillRegistry: {
|
||||||
|
list: ["skill-registry", "skills"] as const,
|
||||||
|
detail: (skillId: string) => ["skill-registry", "skills", skillId] as const,
|
||||||
|
versions: (skillId: string) => ["skill-registry", "skills", skillId, "versions"] as const,
|
||||||
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
all: ["plugins"] as const,
|
all: ["plugins"] as const,
|
||||||
examples: ["plugins", "examples"] as const,
|
examples: ["plugins", "examples"] as const,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue