





















@@ -4,7 +4,9 @@ import path from "node:path";
44import { afterEach, describe, expect, it } from "vitest";
55import type { OpenClawConfig } from "../config/types.openclaw.js";
66import { writeWorkspaceSkills } from "./e2e-test-helpers.js";
7-import { buildSkillIndexCacheKey, SkillsService } from "./service.js";
7+import { buildSkillIndexCacheKey, buildWorkspaceSkillSnapshot, SkillsService } from "./service.js";
8+import { createCanonicalFixtureSkill } from "./test-helpers.js";
9+import type { SkillEntry } from "./types.js";
810import { buildWorkspaceSkillSnapshot as buildLegacyWorkspaceSkillSnapshot } from "./workspace.js";
9111012const tempDirs: string[] = [];
@@ -52,6 +54,29 @@ describe("SkillsService", () => {
5254expect(actual.version).toBe(42);
5355});
545657+it("preserves the preloaded entries snapshot path", () => {
58+const entry: SkillEntry = {
59+skill: createCanonicalFixtureSkill({
60+name: "synthetic-entry-skill",
61+description: "Synthetic entry",
62+filePath: "/synthetic/skills/synthetic-entry-skill/SKILL.md",
63+baseDir: "/synthetic/skills/synthetic-entry-skill",
64+source: "openclaw-workspace",
65+}),
66+frontmatter: {},
67+};
68+69+const snapshot = buildWorkspaceSkillSnapshot("/workspace/that/does/not/exist", {
70+entries: [entry],
71+snapshotVersion: 9,
72+});
73+74+expect(snapshot.prompt).toContain("synthetic-entry-skill");
75+expect(snapshot.skills).toEqual([{ name: "synthetic-entry-skill" }]);
76+expect(snapshot.resolvedSkills).toEqual([entry.skill]);
77+expect(snapshot.version).toBe(9);
78+});
79+5580it("caches the source-aware index until the version key changes", async () => {
5681const workspaceDir = await makeTempWorkspace();
5782await writeWorkspaceSkills(workspaceDir, [
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。