fix: gate skills by OS
This commit is contained in:
@@ -27,6 +27,7 @@ export type ClawdisSkillMetadata = {
|
||||
primaryEnv?: string;
|
||||
emoji?: string;
|
||||
homepage?: string;
|
||||
os?: string[];
|
||||
requires?: {
|
||||
bins?: string[];
|
||||
env?: string[];
|
||||
@@ -188,6 +189,10 @@ export function resolveSkillsInstallPreferences(
|
||||
return { preferBrew, nodeManager };
|
||||
}
|
||||
|
||||
export function resolveRuntimePlatform(): string {
|
||||
return process.platform;
|
||||
}
|
||||
|
||||
export function resolveConfigPath(
|
||||
config: ClawdisConfig | undefined,
|
||||
pathStr: string,
|
||||
@@ -280,6 +285,7 @@ function resolveClawdisMetadata(
|
||||
const install = installRaw
|
||||
.map((entry) => parseInstallSpec(entry))
|
||||
.filter((entry): entry is SkillInstallSpec => Boolean(entry));
|
||||
const osRaw = normalizeStringList(clawdisObj.os);
|
||||
return {
|
||||
always:
|
||||
typeof clawdisObj.always === "boolean" ? clawdisObj.always : undefined,
|
||||
@@ -297,6 +303,7 @@ function resolveClawdisMetadata(
|
||||
typeof clawdisObj.primaryEnv === "string"
|
||||
? clawdisObj.primaryEnv
|
||||
: undefined,
|
||||
os: osRaw.length > 0 ? osRaw : undefined,
|
||||
requires: requiresRaw
|
||||
? {
|
||||
bins: normalizeStringList(requiresRaw.bins),
|
||||
@@ -323,9 +330,13 @@ function shouldIncludeSkill(params: {
|
||||
const skillKey = resolveSkillKey(entry.skill, entry);
|
||||
const skillConfig = resolveSkillConfig(config, skillKey);
|
||||
const allowBundled = normalizeAllowlist(config?.skills?.allowBundled);
|
||||
const osList = entry.clawdis?.os ?? [];
|
||||
|
||||
if (skillConfig?.enabled === false) return false;
|
||||
if (!isBundledSkillAllowed(entry, allowBundled)) return false;
|
||||
if (osList.length > 0 && !osList.includes(resolveRuntimePlatform())) {
|
||||
return false;
|
||||
}
|
||||
if (entry.clawdis?.always === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user