mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix: scope compact skill path env
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
// Compact skill path tests cover short path formatting for skill prompt payloads.
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withEnv } from "../../test-utils/env.js";
|
||||
import { createCanonicalFixtureSkill } from "../test-support/test-helpers.js";
|
||||
import { testing as workspaceSkillsTesting, buildWorkspaceSkillsPrompt } from "./workspace.js";
|
||||
|
||||
describe("compactSkillPaths", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
function buildPromptForFixtureSkill(params: {
|
||||
workspaceRoot: string;
|
||||
skillDir: string;
|
||||
@@ -63,17 +60,21 @@ describe("compactSkillPaths", () => {
|
||||
const skillDir = path.join(stateDir, "skills", "world-cup-soccer-openclaw-skill");
|
||||
const skillFile = path.join(skillDir, "SKILL.md");
|
||||
|
||||
vi.stubEnv("HOME", osHome);
|
||||
vi.stubEnv("OPENCLAW_HOME", osHome);
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
vi.stubEnv("OPENCLAW_CONFIG_PATH", path.join(stateDir, "openclaw.json"));
|
||||
|
||||
const prompt = buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(root, "workspace"),
|
||||
skillDir,
|
||||
name: "world-cup-soccer-openclaw-skill",
|
||||
description: "World Cup standings lookup",
|
||||
});
|
||||
const prompt = withEnv(
|
||||
{
|
||||
HOME: osHome,
|
||||
OPENCLAW_HOME: osHome,
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
OPENCLAW_CONFIG_PATH: path.join(stateDir, "openclaw.json"),
|
||||
},
|
||||
() =>
|
||||
buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(root, "workspace"),
|
||||
skillDir,
|
||||
name: "world-cup-soccer-openclaw-skill",
|
||||
description: "World Cup standings lookup",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(prompt).toContain(`<location>${skillFile}</location>`);
|
||||
expect(prompt).not.toContain("~/.openclaw/skills/world-cup-soccer-openclaw-skill/SKILL.md");
|
||||
@@ -86,17 +87,21 @@ describe("compactSkillPaths", () => {
|
||||
const skillDir = path.join(stateDir, "plugin-skills", "calendar-plugin-skill");
|
||||
const skillFile = path.join(skillDir, "SKILL.md");
|
||||
|
||||
vi.stubEnv("HOME", osHome);
|
||||
vi.stubEnv("OPENCLAW_HOME", osHome);
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
vi.stubEnv("OPENCLAW_CONFIG_PATH", path.join(stateDir, "openclaw.json"));
|
||||
|
||||
const prompt = buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(root, "workspace"),
|
||||
skillDir,
|
||||
name: "calendar-plugin-skill",
|
||||
description: "Calendar plugin skill",
|
||||
});
|
||||
const prompt = withEnv(
|
||||
{
|
||||
HOME: osHome,
|
||||
OPENCLAW_HOME: osHome,
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
OPENCLAW_CONFIG_PATH: path.join(stateDir, "openclaw.json"),
|
||||
},
|
||||
() =>
|
||||
buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(root, "workspace"),
|
||||
skillDir,
|
||||
name: "calendar-plugin-skill",
|
||||
description: "Calendar plugin skill",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(prompt).toContain(`<location>${skillFile}</location>`);
|
||||
expect(prompt).not.toContain("~/.openclaw/plugin-skills/calendar-plugin-skill/SKILL.md");
|
||||
@@ -107,16 +112,20 @@ describe("compactSkillPaths", () => {
|
||||
const stateDir = path.join(home, ".openclaw");
|
||||
const skillDir = path.join(stateDir, "skills", "home-managed-skill");
|
||||
|
||||
vi.stubEnv("HOME", home);
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
vi.stubEnv("OPENCLAW_HOME", undefined);
|
||||
|
||||
const prompt = buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(home, "workspace"),
|
||||
skillDir,
|
||||
name: "home-managed-skill",
|
||||
description: "Home managed skill",
|
||||
});
|
||||
const prompt = withEnv(
|
||||
{
|
||||
HOME: home,
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
OPENCLAW_HOME: undefined,
|
||||
},
|
||||
() =>
|
||||
buildPromptForFixtureSkill({
|
||||
workspaceRoot: path.join(home, "workspace"),
|
||||
skillDir,
|
||||
name: "home-managed-skill",
|
||||
description: "Home managed skill",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(prompt).toContain("<location>~/.openclaw/skills/home-managed-skill/SKILL.md</location>");
|
||||
expect(prompt).not.toContain(`<location>${path.join(skillDir, "SKILL.md")}</location>`);
|
||||
|
||||
Reference in New Issue
Block a user