refactor: drop legacy skill source fallback

This commit is contained in:
Peter Steinberger 2026-03-28 03:45:19 +00:00
parent 24bb64b1c4
commit ec6fba7d01
3 changed files with 11 additions and 25 deletions

View File

@ -10,14 +10,6 @@ describe("resolveSkillSource", () => {
).toBe("openclaw-bundled");
});
it("falls back to legacy top-level source", () => {
expect(
resolveSkillSource({
source: "openclaw-managed",
} as never),
).toBe("openclaw-managed");
});
it("returns unknown when neither source shape is present", () => {
expect(resolveSkillSource({} as never)).toBe("unknown");
});

View File

@ -1,5 +1,9 @@
import os from "node:os";
import { formatSkillsForPrompt, type Skill } from "@mariozechner/pi-coding-agent";
import {
createSyntheticSourceInfo,
formatSkillsForPrompt,
type Skill,
} from "@mariozechner/pi-coding-agent";
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../../config/config.js";
import type { SkillEntry } from "./types.js";
@ -15,7 +19,10 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
description: desc,
filePath,
baseDir: `/skills/${name}`,
source: "workspace",
sourceInfo: createSyntheticSourceInfo(filePath, {
source: "workspace",
baseDir: `/skills/${name}`,
}),
disableModelInvocation: false,
};
}

View File

@ -1,19 +1,6 @@
import type { Skill } from "@mariozechner/pi-coding-agent";
type SkillSourceShapeCompat = Skill & {
source?: string;
sourceInfo?: {
source?: string;
};
};
export function resolveSkillSource(skill: Skill): string {
const compatSkill = skill as SkillSourceShapeCompat;
const sourceInfoSource =
typeof compatSkill.sourceInfo?.source === "string" ? compatSkill.sourceInfo.source.trim() : "";
if (sourceInfoSource) {
return sourceInfoSource;
}
const legacySource = typeof compatSkill.source === "string" ? compatSkill.source.trim() : "";
return legacySource || "unknown";
const source = typeof skill.sourceInfo?.source === "string" ? skill.sourceInfo.source.trim() : "";
return source || "unknown";
}