mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
refactor: drop legacy skill source fallback
This commit is contained in:
@@ -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");
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user