Skip to content

Commit d4ce4fa

Browse files
Skills: enabled: true now overrides requires.bins check (#32752)
1 parent 924b9d7 commit d4ce4fa

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/agents/skills/config.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { describe, expect, it, vi } from "vitest";
2+
import type { OpenClawConfig } from "../../config/config.js";
3+
import type { SkillEntry } from "./types.js";
4+
import { shouldIncludeSkill } from "./config.js";
5+
6+
/**
7+
* Build a minimal SkillEntry for testing shouldIncludeSkill.
8+
*/
9+
function makeEntry(overrides?: {
10+
name?: string;
11+
source?: string;
12+
requiresBins?: string[];
13+
}): SkillEntry {
14+
const name = overrides?.name ?? "test-skill";
15+
return {
16+
skill: {
17+
name,
18+
description: "A test skill",
19+
filePath: `/skills/${name}/SKILL.md`,
20+
baseDir: `/skills/${name}`,
21+
source: overrides?.source ?? "user",
22+
disableModelInvocation: false,
23+
},
24+
frontmatter: {},
25+
metadata: overrides?.requiresBins
26+
? { requires: { bins: overrides.requiresBins } }
27+
: undefined,
28+
};
29+
}
30+
31+
describe("shouldIncludeSkill", () => {
32+
it("returns false when enabled is explicitly false", () => {
33+
const entry = makeEntry();
34+
const config: OpenClawConfig = {
35+
skills: { entries: { "test-skill": { enabled: false } } },
36+
} as OpenClawConfig;
37+
expect(shouldIncludeSkill({ entry, config })).toBe(false);
38+
});
39+
40+
it("returns true when enabled is explicitly true, even with unmet requires.bins", () => {
41+
const entry = makeEntry({ requiresBins: ["nonexistent-binary-xyz"] });
42+
const config: OpenClawConfig = {
43+
skills: { entries: { "test-skill": { enabled: true } } },
44+
} as OpenClawConfig;
45+
expect(shouldIncludeSkill({ entry, config })).toBe(true);
46+
});
47+
48+
it("returns true when enabled is explicitly true without any requires", () => {
49+
const entry = makeEntry();
50+
const config: OpenClawConfig = {
51+
skills: { entries: { "test-skill": { enabled: true } } },
52+
} as OpenClawConfig;
53+
expect(shouldIncludeSkill({ entry, config })).toBe(true);
54+
});
55+
56+
it("falls through to runtime eligibility when enabled is not set", () => {
57+
// A skill requiring a nonexistent binary should be excluded when
58+
// there is no explicit enabled override.
59+
const entry = makeEntry({ requiresBins: ["nonexistent-binary-xyz"] });
60+
const config: OpenClawConfig = {
61+
skills: { entries: { "test-skill": {} } },
62+
} as OpenClawConfig;
63+
expect(shouldIncludeSkill({ entry, config })).toBe(false);
64+
});
65+
66+
it("falls through to runtime eligibility when no skill config exists", () => {
67+
const entry = makeEntry({ requiresBins: ["nonexistent-binary-xyz"] });
68+
expect(shouldIncludeSkill({ entry })).toBe(false);
69+
});
70+
});

src/agents/skills/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ export function shouldIncludeSkill(params: {
8080
if (skillConfig?.enabled === false) {
8181
return false;
8282
}
83+
if (skillConfig?.enabled === true) {
84+
return true;
85+
}
8386
if (!isBundledSkillAllowed(entry, allowBundled)) {
8487
return false;
8588
}

0 commit comments

Comments
 (0)