diff --git a/server/src/routes/skill-registry-groups.ts b/server/src/routes/skill-registry-groups.ts index f8998fd2..35073699 100644 --- a/server/src/routes/skill-registry-groups.ts +++ b/server/src/routes/skill-registry-groups.ts @@ -7,9 +7,22 @@ import { skillGroupService } from "../services/skill-registry-groups.js"; import { skillRegistryService } from "../services/skill-registry.js"; import { assertBoard } from "./authz.js"; -/** Default skills directory when client doesn't provide one */ -function defaultSkillsDir(): string { - return path.join(os.homedir(), ".claude", "skills"); +/** + * Resolves the agentSkillsDir for a given agentId by looking up the agent's + * adapter type and calling resolveAdapterSkillConfig. Throws with a status + * property so route handlers can forward the correct HTTP status code. + */ +async function resolveSkillsDirForAgent(db: Db, agentId: string): Promise { + const agent = await agentService(db).getById(agentId); + if (!agent) throw Object.assign(new Error("Agent not found"), { status: 404 }); + const config = resolveAdapterSkillConfig(agent.adapterType); + if (!config.supportsInstall || !config.skillDir) { + throw Object.assign( + new Error(config.unsupportedReason ?? "Adapter does not support skill install"), + { status: 422 }, + ); + } + return config.skillDir.replace(/^~/, os.homedir()); } /**