Skip to content

Commit fa6a189

Browse files
feat(skills): hub-backed skill catalog + install (anomalyco#528)
* feat(skills): browse and install hub skills * fix(skills): tolerate missing hub metadata
1 parent e21834e commit fa6a189

10 files changed

Lines changed: 667 additions & 3 deletions

File tree

‎packages/app/src/app/app.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,8 @@ export default function App() {
12431243
const {
12441244
skills,
12451245
skillsStatus,
1246+
hubSkills,
1247+
hubSkillsStatus,
12461248
pluginScope,
12471249
setPluginScope,
12481250
pluginConfig,
@@ -1257,10 +1259,12 @@ export default function App() {
12571259
sidebarPluginStatus,
12581260
isPluginInstalledByName,
12591261
refreshSkills,
1262+
refreshHubSkills,
12601263
refreshPlugins,
12611264
addPlugin,
12621265
importLocalSkill,
12631266
installSkillCreator,
1267+
installHubSkill,
12641268
revealSkillsFolder,
12651269
uninstallSkill,
12661270
readSkill,
@@ -4465,15 +4469,19 @@ export default function App() {
44654469
deleteScheduledJob,
44664470
activeWorkspaceRoot: workspaceStore.activeWorkspaceRoot().trim(),
44674471
refreshSkills: (options?: { force?: boolean }) => refreshSkills(options).catch(() => undefined),
4472+
refreshHubSkills: (options?: { force?: boolean }) => refreshHubSkills(options).catch(() => undefined),
44684473
refreshPlugins: (scopeOverride?: PluginScope) =>
44694474
refreshPlugins(scopeOverride).catch(() => undefined),
44704475
skills: skills(),
44714476
skillsStatus: skillsStatus(),
4477+
hubSkills: hubSkills(),
4478+
hubSkillsStatus: hubSkillsStatus(),
44724479
skillsAccessHint,
44734480
canInstallSkillCreator,
44744481
canUseDesktopTools,
44754482
importLocalSkill,
44764483
installSkillCreator,
4484+
installHubSkill,
44774485
revealSkillsFolder,
44784486
uninstallSkill,
44794487
readSkill,

‎packages/app/src/app/context/extensions.ts‎

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { applyEdits, modify } from "jsonc-parser";
44
import { join } from "@tauri-apps/api/path";
55
import { currentLocale, t } from "../../i18n";
66

7-
import type { Client, PluginScope, ReloadReason, ReloadTrigger, SkillCard } from "../types";
7+
import type { Client, HubSkillCard, PluginScope, ReloadReason, ReloadTrigger, SkillCard } from "../types";
88
import { addOpencodeCacheHint, isTauriRuntime } from "../utils";
99
import skillCreatorTemplate from "../data/skill-creator.md?raw";
1010
import {
@@ -55,6 +55,9 @@ export function createExtensionsStore(options: {
5555
const [skills, setSkills] = createSignal<SkillCard[]>([]);
5656
const [skillsStatus, setSkillsStatus] = createSignal<string | null>(null);
5757

58+
const [hubSkills, setHubSkills] = createSignal<HubSkillCard[]>([]);
59+
const [hubSkillsStatus, setHubSkillsStatus] = createSignal<string | null>(null);
60+
5861
const formatSkillPath = (location: string) => location.replace(/[/\\]SKILL\.md$/i, "");
5962

6063
const [pluginScope, setPluginScope] = createSignal<PluginScope>("project");
@@ -71,10 +74,132 @@ export function createExtensionsStore(options: {
7174
// Track in-flight requests to prevent duplicate calls
7275
let refreshSkillsInFlight = false;
7376
let refreshPluginsInFlight = false;
77+
let refreshHubSkillsInFlight = false;
7478
let refreshSkillsAborted = false;
7579
let refreshPluginsAborted = false;
80+
let refreshHubSkillsAborted = false;
7681
let skillsLoaded = false;
82+
let hubSkillsLoaded = false;
7783
let skillsRoot = "";
84+
let hubSkillsRoot = "";
85+
86+
async function refreshHubSkills(optionsOverride?: { force?: boolean }) {
87+
const root = options.activeWorkspaceRoot().trim();
88+
const openworkClient = options.openworkServerClient();
89+
const openworkCapabilities = options.openworkServerCapabilities();
90+
const canUseOpenworkServer =
91+
options.openworkServerStatus() === "connected" &&
92+
openworkClient &&
93+
openworkCapabilities?.hub?.skills?.read &&
94+
typeof (openworkClient as any).listHubSkills === "function";
95+
96+
if (root !== hubSkillsRoot) {
97+
hubSkillsLoaded = false;
98+
}
99+
100+
if (!optionsOverride?.force && hubSkillsLoaded) return;
101+
if (refreshHubSkillsInFlight) return;
102+
103+
refreshHubSkillsInFlight = true;
104+
refreshHubSkillsAborted = false;
105+
106+
try {
107+
setHubSkillsStatus(null);
108+
109+
if (canUseOpenworkServer) {
110+
const response = await (openworkClient as any).listHubSkills();
111+
if (refreshHubSkillsAborted) return;
112+
const next: HubSkillCard[] = Array.isArray(response?.items)
113+
? response.items.map((entry: any) => ({
114+
name: String(entry.name ?? ""),
115+
description: typeof entry.description === "string" ? entry.description : undefined,
116+
trigger: typeof entry.trigger === "string" ? entry.trigger : undefined,
117+
source: entry.source,
118+
}))
119+
: [];
120+
setHubSkills(next);
121+
if (!next.length) setHubSkillsStatus("No hub skills found.");
122+
hubSkillsLoaded = true;
123+
hubSkillsRoot = root;
124+
return;
125+
}
126+
127+
// Browser fallback: fetch directly from GitHub (public catalog).
128+
const listingRes = await fetch("https://api.github.com/repos/different-ai/openwork-hub/contents/skills?ref=main", {
129+
headers: { Accept: "application/vnd.github+json" },
130+
});
131+
if (!listingRes.ok) {
132+
throw new Error(`Failed to fetch hub catalog (${listingRes.status})`);
133+
}
134+
const listing = (await listingRes.json()) as any;
135+
const dirs: string[] = Array.isArray(listing)
136+
? listing
137+
.filter((entry) => entry && entry.type === "dir" && typeof entry.name === "string")
138+
.map((entry) => String(entry.name))
139+
: [];
140+
141+
const next: HubSkillCard[] = dirs.map((dirName) => ({
142+
name: dirName,
143+
source: { owner: "different-ai", repo: "openwork-hub", ref: "main", path: `skills/${dirName}` },
144+
}));
145+
146+
if (refreshHubSkillsAborted) return;
147+
const sorted = next.slice().sort((a, b) => a.name.localeCompare(b.name));
148+
setHubSkills(sorted);
149+
if (!sorted.length) setHubSkillsStatus("No hub skills found.");
150+
hubSkillsLoaded = true;
151+
hubSkillsRoot = root;
152+
} catch (e) {
153+
if (refreshHubSkillsAborted) return;
154+
setHubSkills([]);
155+
setHubSkillsStatus(e instanceof Error ? e.message : "Failed to load hub skills.");
156+
} finally {
157+
refreshHubSkillsInFlight = false;
158+
}
159+
}
160+
161+
async function installHubSkill(name: string): Promise<{ ok: boolean; message: string }> {
162+
const trimmed = name.trim();
163+
if (!trimmed) return { ok: false, message: "Skill name is required." };
164+
165+
const isRemoteWorkspace = options.workspaceType() === "remote";
166+
const openworkClient = options.openworkServerClient();
167+
const openworkWorkspaceId = options.openworkServerWorkspaceId();
168+
const openworkCapabilities = options.openworkServerCapabilities();
169+
const canUseOpenworkServer =
170+
options.openworkServerStatus() === "connected" &&
171+
openworkClient &&
172+
openworkWorkspaceId &&
173+
openworkCapabilities?.hub?.skills?.install &&
174+
typeof (openworkClient as any).installHubSkill === "function";
175+
176+
if (!canUseOpenworkServer) {
177+
if (isRemoteWorkspace) {
178+
return { ok: false, message: "OpenWork server unavailable. Connect to install skills." };
179+
}
180+
return { ok: false, message: "Hub install requires OpenWork server." };
181+
}
182+
183+
options.setBusy(true);
184+
options.setError(null);
185+
setSkillsStatus(null);
186+
187+
try {
188+
const result = await (openworkClient as any).installHubSkill(openworkWorkspaceId, trimmed);
189+
await refreshSkills({ force: true });
190+
await refreshHubSkills({ force: true });
191+
if (!result?.ok) {
192+
return { ok: false, message: "Install failed." };
193+
}
194+
return { ok: true, message: `Installed ${trimmed}.` };
195+
} catch (e) {
196+
const message = e instanceof Error ? e.message : translate("skills.unknown_error");
197+
options.setError(addOpencodeCacheHint(message));
198+
return { ok: false, message };
199+
} finally {
200+
options.setBusy(false);
201+
}
202+
}
78203

79204
const isPluginInstalledByName = (pluginName: string, aliases: string[] = []) =>
80205
isPluginInstalled(pluginList(), pluginName, aliases);
@@ -895,11 +1020,14 @@ export function createExtensionsStore(options: {
8951020
function abortRefreshes() {
8961021
refreshSkillsAborted = true;
8971022
refreshPluginsAborted = true;
1023+
refreshHubSkillsAborted = true;
8981024
}
8991025

9001026
return {
9011027
skills,
9021028
skillsStatus,
1029+
hubSkills,
1030+
hubSkillsStatus,
9031031
pluginScope,
9041032
setPluginScope,
9051033
pluginConfig,
@@ -914,10 +1042,12 @@ export function createExtensionsStore(options: {
9141042
sidebarPluginStatus,
9151043
isPluginInstalledByName,
9161044
refreshSkills,
1045+
refreshHubSkills,
9171046
refreshPlugins,
9181047
addPlugin,
9191048
importLocalSkill,
9201049
installSkillCreator,
1050+
installHubSkill,
9211051
revealSkillsFolder,
9221052
uninstallSkill,
9231053
readSkill,

‎packages/app/src/app/lib/openwork-server.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import type { ScheduledJob } from "./tauri";
44

55
export type OpenworkServerCapabilities = {
66
skills: { read: boolean; write: boolean; source: "openwork" | "opencode" };
7+
hub?: {
8+
skills?: {
9+
read: boolean;
10+
install: boolean;
11+
repo?: { owner: string; name: string; ref: string };
12+
};
13+
};
714
plugins: { read: boolean; write: boolean };
815
mcp: { read: boolean; write: boolean };
916
commands: { read: boolean; write: boolean };
@@ -74,6 +81,18 @@ export type OpenworkSkillContent = {
7481
content: string;
7582
};
7683

84+
export type OpenworkHubSkillItem = {
85+
name: string;
86+
description: string;
87+
trigger?: string;
88+
source: {
89+
owner: string;
90+
repo: string;
91+
ref: string;
92+
path: string;
93+
};
94+
};
95+
7796
export type OpenworkWorkspaceFileContent = {
7897
path: string;
7998
content: string;
@@ -984,6 +1003,29 @@ export function createOpenworkServerClient(options: { baseUrl: string; token?: s
9841003
{ token, hostToken },
9851004
);
9861005
},
1006+
listHubSkills: () =>
1007+
requestJson<{ items: OpenworkHubSkillItem[] }>(baseUrl, `/hub/skills`, {
1008+
token,
1009+
hostToken,
1010+
}),
1011+
installHubSkill: (
1012+
workspaceId: string,
1013+
name: string,
1014+
options?: { overwrite?: boolean; repo?: { owner?: string; repo?: string; ref?: string } },
1015+
) =>
1016+
requestJson<{ ok: boolean; name: string; path: string; action: "added" | "updated"; written: number; skipped: number }>(
1017+
baseUrl,
1018+
`/workspace/${workspaceId}/skills/hub/${encodeURIComponent(name)}`,
1019+
{
1020+
token,
1021+
hostToken,
1022+
method: "POST",
1023+
body: {
1024+
...(options?.overwrite ? { overwrite: true } : {}),
1025+
...(options?.repo ? { repo: options.repo } : {}),
1026+
},
1027+
},
1028+
),
9871029
getSkill: (workspaceId: string, name: string, options?: { includeGlobal?: boolean }) => {
9881030
const query = options?.includeGlobal ? "?includeGlobal=true" : "";
9891031
return requestJson<OpenworkSkillContent>(

‎packages/app/src/app/pages/dashboard.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
ProviderListItem,
99
SettingsTab,
1010
ScheduledJob,
11+
HubSkillCard,
1112
SkillCard,
1213
StartupPreference,
1314
WorkspaceSessionGroup,
@@ -132,15 +133,19 @@ export type DashboardViewProps = {
132133
deleteScheduledJob: (name: string) => Promise<void> | void;
133134
activeWorkspaceRoot: string;
134135
refreshSkills: (options?: { force?: boolean }) => void;
136+
refreshHubSkills: (options?: { force?: boolean }) => void;
135137
refreshPlugins: (scopeOverride?: PluginScope) => void;
136138
refreshMcpServers: () => void;
137139
skills: SkillCard[];
138140
skillsStatus: string | null;
141+
hubSkills: HubSkillCard[];
142+
hubSkillsStatus: string | null;
139143
skillsAccessHint?: string | null;
140144
canInstallSkillCreator: boolean;
141145
canUseDesktopTools: boolean;
142146
importLocalSkill: () => void;
143147
installSkillCreator: () => Promise<{ ok: boolean; message: string }>;
148+
installHubSkill: (name: string) => Promise<{ ok: boolean; message: string }>;
144149
revealSkillsFolder: () => void;
145150
uninstallSkill: (name: string) => void;
146151
readSkill: (name: string) => Promise<{ name: string; path: string; content: string } | null>;
@@ -1153,10 +1158,14 @@ export default function DashboardView(props: DashboardViewProps) {
11531158
canUseDesktopTools={props.canUseDesktopTools}
11541159
accessHint={props.skillsAccessHint}
11551160
refreshSkills={props.refreshSkills}
1161+
refreshHubSkills={props.refreshHubSkills}
11561162
skills={props.skills}
11571163
skillsStatus={props.skillsStatus}
1164+
hubSkills={props.hubSkills}
1165+
hubSkillsStatus={props.hubSkillsStatus}
11581166
importLocalSkill={props.importLocalSkill}
11591167
installSkillCreator={props.installSkillCreator}
1168+
installHubSkill={props.installHubSkill}
11601169
revealSkillsFolder={props.revealSkillsFolder}
11611170
uninstallSkill={props.uninstallSkill}
11621171
readSkill={props.readSkill}

0 commit comments

Comments
 (0)