mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:10:45 +00:00
fix(skills): honor legacy clawdbot metadata
This commit is contained in:
committed by
Peter Steinberger
parent
49f72b332f
commit
bb5f523068
@@ -14,6 +14,12 @@ afterEach(async () => {
|
||||
await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
|
||||
});
|
||||
|
||||
async function createTempWorkspaceDir() {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-skill-status-"));
|
||||
tempDirs.push(workspaceDir);
|
||||
return workspaceDir;
|
||||
}
|
||||
|
||||
function makeEntry(params: {
|
||||
name: string;
|
||||
source?: string;
|
||||
@@ -94,6 +100,36 @@ describe("buildWorkspaceSkillStatus", () => {
|
||||
expect(skill?.missing.config).toContain("browser.enabled");
|
||||
expect(skill?.install[0]?.id).toBe("brew");
|
||||
});
|
||||
|
||||
it("honors legacy clawdbot skill metadata requirements and install hints", async () => {
|
||||
const workspaceDir = await createTempWorkspaceDir();
|
||||
await writeSkill({
|
||||
dir: path.join(workspaceDir, "skills", "legacy-skill"),
|
||||
name: "legacy-skill",
|
||||
description: "Legacy metadata",
|
||||
metadata:
|
||||
'{"clawdbot":{"requires":{"bins":["fakebin"]},"install":[{"id":"brew","kind":"brew","formula":"fakebin","bins":["fakebin"],"label":"Install fakebin"}]}}',
|
||||
});
|
||||
|
||||
const report = withEnv({ PATH: "" }, () =>
|
||||
buildWorkspaceSkillStatus(workspaceDir, {
|
||||
managedSkillsDir: path.join(workspaceDir, ".managed"),
|
||||
}),
|
||||
);
|
||||
const skill = report.skills.find((entry) => entry.name === "legacy-skill");
|
||||
|
||||
expect(skill).toBeDefined();
|
||||
expect(skill?.eligible).toBe(false);
|
||||
expect(skill?.requirements.bins).toEqual(["fakebin"]);
|
||||
expect(skill?.missing.bins).toEqual(["fakebin"]);
|
||||
expect(skill?.install[0]).toMatchObject({
|
||||
id: "brew",
|
||||
kind: "brew",
|
||||
label: "Install fakebin",
|
||||
bins: ["fakebin"],
|
||||
});
|
||||
});
|
||||
|
||||
it("respects OS-gated skills", async () => {
|
||||
const entry = makeEntry({
|
||||
name: "os-skill",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const PROJECT_NAME = "openclaw" as const;
|
||||
|
||||
export const LEGACY_PROJECT_NAMES = [] as const;
|
||||
export const LEGACY_PROJECT_NAMES = ["clawdbot"] as const;
|
||||
|
||||
export const MANIFEST_KEY = PROJECT_NAME;
|
||||
|
||||
|
||||
@@ -49,6 +49,16 @@ describe("shared/frontmatter", () => {
|
||||
).toEqual({ foo: 2 });
|
||||
});
|
||||
|
||||
test("resolveOpenClawManifestBlock reads legacy manifest keys", () => {
|
||||
expect(
|
||||
resolveOpenClawManifestBlock({
|
||||
frontmatter: {
|
||||
metadata: "{ clawdbot: { requires: { bins: ['op'] }, install: [] } }",
|
||||
},
|
||||
}),
|
||||
).toEqual({ requires: { bins: ["op"] }, install: [] });
|
||||
});
|
||||
|
||||
test("resolveOpenClawManifestBlock returns undefined for invalid input", () => {
|
||||
expect(resolveOpenClawManifestBlock({ frontmatter: {} })).toBeUndefined();
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user