mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 00:04:32 +00:00
refactor(agents): dedupe workspace and session tool flows
This commit is contained in:
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createTrackedTempDirs } from "../test-utils/tracked-temp-dirs.js";
|
||||
import { writeSkill } from "./skills.e2e-test-helpers.js";
|
||||
import { buildWorkspaceSkillSnapshot } from "./skills.js";
|
||||
import { buildWorkspaceSkillSnapshot, buildWorkspaceSkillsPrompt } from "./skills.js";
|
||||
|
||||
const tempDirs = createTrackedTempDirs();
|
||||
|
||||
@@ -51,6 +51,40 @@ describe("buildWorkspaceSkillSnapshot", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps prompt output aligned with buildWorkspaceSkillsPrompt", async () => {
|
||||
const workspaceDir = await tempDirs.make("openclaw-");
|
||||
await writeSkill({
|
||||
dir: path.join(workspaceDir, "skills", "visible"),
|
||||
name: "visible",
|
||||
description: "Visible",
|
||||
});
|
||||
await writeSkill({
|
||||
dir: path.join(workspaceDir, "skills", "hidden"),
|
||||
name: "hidden",
|
||||
description: "Hidden",
|
||||
frontmatterExtra: "disable-model-invocation: true",
|
||||
});
|
||||
const config = {
|
||||
skills: {
|
||||
limits: {
|
||||
maxSkillsInPrompt: 1,
|
||||
maxSkillsPromptChars: 200,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
const opts = {
|
||||
config,
|
||||
managedSkillsDir: path.join(workspaceDir, ".managed"),
|
||||
bundledSkillsDir: path.join(workspaceDir, ".bundled"),
|
||||
eligibility: { remote: { note: "Remote note" } },
|
||||
} as const;
|
||||
|
||||
const snapshot = buildWorkspaceSkillSnapshot(workspaceDir, opts);
|
||||
const prompt = buildWorkspaceSkillsPrompt(workspaceDir, opts);
|
||||
|
||||
expect(snapshot.prompt).toBe(prompt);
|
||||
});
|
||||
|
||||
it("truncates the skills prompt when it exceeds the configured char budget", async () => {
|
||||
const workspaceDir = await tempDirs.make("openclaw-");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user