mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 21:50:22 +00:00
Diffs: Migrate tool usage guidance from before_prompt_build to a plugin skill (#32630)
Merged via squash.
Prepared head SHA: 585697a4e1
Co-authored-by: sircrumpet <4436535+sircrumpet@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -48,6 +48,36 @@ async function setupWorkspaceWithProsePlugin() {
|
||||
return { workspaceDir, managedDir, bundledDir };
|
||||
}
|
||||
|
||||
async function setupWorkspaceWithDiffsPlugin() {
|
||||
const workspaceDir = await createTempWorkspaceDir();
|
||||
const managedDir = path.join(workspaceDir, ".managed");
|
||||
const bundledDir = path.join(workspaceDir, ".bundled");
|
||||
const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "diffs");
|
||||
|
||||
await fs.mkdir(path.join(pluginRoot, "skills", "diffs"), { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(pluginRoot, "openclaw.plugin.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
id: "diffs",
|
||||
skills: ["./skills"],
|
||||
configSchema: { type: "object", additionalProperties: false, properties: {} },
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf-8",
|
||||
);
|
||||
await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8");
|
||||
await fs.writeFile(
|
||||
path.join(pluginRoot, "skills", "diffs", "SKILL.md"),
|
||||
`---\nname: diffs\ndescription: test\n---\n`,
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
return { workspaceDir, managedDir, bundledDir };
|
||||
}
|
||||
|
||||
describe("loadWorkspaceSkillEntries", () => {
|
||||
it("handles an empty managed skills dir without throwing", async () => {
|
||||
const workspaceDir = await createTempWorkspaceDir();
|
||||
@@ -93,4 +123,36 @@ describe("loadWorkspaceSkillEntries", () => {
|
||||
|
||||
expect(entries.map((entry) => entry.skill.name)).not.toContain("prose");
|
||||
});
|
||||
|
||||
it("includes diffs plugin skill when the plugin is enabled", async () => {
|
||||
const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithDiffsPlugin();
|
||||
|
||||
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
||||
config: {
|
||||
plugins: {
|
||||
entries: { diffs: { enabled: true } },
|
||||
},
|
||||
},
|
||||
managedSkillsDir: managedDir,
|
||||
bundledSkillsDir: bundledDir,
|
||||
});
|
||||
|
||||
expect(entries.map((entry) => entry.skill.name)).toContain("diffs");
|
||||
});
|
||||
|
||||
it("excludes diffs plugin skill when the plugin is disabled", async () => {
|
||||
const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithDiffsPlugin();
|
||||
|
||||
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
||||
config: {
|
||||
plugins: {
|
||||
entries: { diffs: { enabled: false } },
|
||||
},
|
||||
},
|
||||
managedSkillsDir: managedDir,
|
||||
bundledSkillsDir: bundledDir,
|
||||
});
|
||||
|
||||
expect(entries.map((entry) => entry.skill.name)).not.toContain("diffs");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user