Skip to content

Commit 05ba226

Browse files
steipeteAlix-007
andauthored
test(skills): isolate description limit regression coverage
Co-authored-by: Alix-007 <[email protected]>
1 parent 04db7ec commit 05ba226

2 files changed

Lines changed: 81 additions & 55 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import fs from "node:fs/promises";
2+
import path from "node:path";
3+
import { validateToolArguments } from "openclaw/plugin-sdk/llm";
4+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
5+
import {
6+
createOpenClawTestState,
7+
type OpenClawTestState,
8+
} from "../../test-utils/openclaw-test-state.js";
9+
import { createTrackedTempDirs } from "../../test-utils/tracked-temp-dirs.js";
10+
import { createSkillWorkshopTool } from "./skill-workshop-tool.js";
11+
12+
const tempDirs = createTrackedTempDirs();
13+
let testState: OpenClawTestState;
14+
15+
beforeEach(async () => {
16+
testState = await createOpenClawTestState({
17+
layout: "state-only",
18+
prefix: "openclaw-skill-workshop-description-state-",
19+
});
20+
});
21+
22+
afterEach(async () => {
23+
await testState.cleanup();
24+
await tempDirs.cleanup();
25+
});
26+
27+
describe("skill_workshop description validation", () => {
28+
it("lets the proposal service explain overlong descriptions", async () => {
29+
const workspaceDir = await tempDirs.make("openclaw-skill-workshop-description-limit-");
30+
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env });
31+
const args = {
32+
action: "create" as const,
33+
name: "Long Description",
34+
description: "x".repeat(161),
35+
proposal_content: "# Long Description\n",
36+
};
37+
const call = {
38+
type: "toolCall" as const,
39+
id: "call-long-description",
40+
name: "skill_workshop",
41+
arguments: args,
42+
};
43+
expect(validateToolArguments(tool, call)).toEqual(args);
44+
45+
await expect(tool.execute(call.id, args)).rejects.toThrow(
46+
"Skill proposal description is too large (161 bytes, max 160).",
47+
);
48+
});
49+
50+
it("lets the proposal service explain overlong collection descriptions", async () => {
51+
const workspaceDir = await tempDirs.make("openclaw-skill-collection-description-limit-");
52+
const collectionReconcile = {};
53+
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env, collectionReconcile });
54+
const args = {
55+
action: "reconcile" as const,
56+
collection: [
57+
{
58+
action: "write" as const,
59+
name: "long-description",
60+
description: "x".repeat(161),
61+
content: "# Long Description\n",
62+
},
63+
],
64+
};
65+
const call = {
66+
type: "toolCall" as const,
67+
id: "call-long-collection-description",
68+
name: "skill_workshop",
69+
arguments: args,
70+
};
71+
expect(validateToolArguments(tool, call)).toEqual(args);
72+
73+
await expect(tool.execute(call.id, args)).rejects.toThrow(
74+
"Skill proposal description is too large (161 bytes, max 160).",
75+
);
76+
await expect(
77+
fs.access(path.join(workspaceDir, "skills", "long-description", "SKILL.md")),
78+
).rejects.toThrow();
79+
expect(collectionReconcile).not.toHaveProperty("result");
80+
});
81+
});

‎src/agents/tools/skill-workshop-tool.test.ts‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// applying generated skills to the workspace.
33
import fs from "node:fs/promises";
44
import path from "node:path";
5-
import { validateToolArguments } from "openclaw/plugin-sdk/llm";
65
import { afterEach, beforeEach, describe, expect, it } from "vitest";
76
import { consumeRunSkillUsage, recordRunSkillUsage } from "../../skills/runtime/run-usage.js";
87
import { writeWorkspaceSkills } from "../../skills/test-support/e2e-test-helpers.js";
@@ -210,60 +209,6 @@ describe("skill_workshop tool", () => {
210209
expect(tool.description).toContain(SKILL_AUTHORING_STANDARDS_PROMPT);
211210
});
212211

213-
it("lets the proposal service explain overlong descriptions", async () => {
214-
const workspaceDir = await tempDirs.make("openclaw-skill-workshop-description-limit-");
215-
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env });
216-
const args = {
217-
action: "create" as const,
218-
name: "Long Description",
219-
description: "x".repeat(161),
220-
proposal_content: "# Long Description\n",
221-
};
222-
const call = {
223-
type: "toolCall" as const,
224-
id: "call-long-description",
225-
name: "skill_workshop",
226-
arguments: args,
227-
};
228-
expect(validateToolArguments(tool, call)).toEqual(args);
229-
230-
await expect(tool.execute(call.id, args)).rejects.toThrow(
231-
"Skill proposal description is too large (161 bytes, max 160).",
232-
);
233-
});
234-
235-
it("lets the proposal service explain overlong collection descriptions", async () => {
236-
const workspaceDir = await tempDirs.make("openclaw-skill-collection-description-limit-");
237-
const collectionReconcile = {};
238-
const tool = createSkillWorkshopTool({ workspaceDir, env: testState.env, collectionReconcile });
239-
const args = {
240-
action: "reconcile" as const,
241-
collection: [
242-
{
243-
action: "write" as const,
244-
name: "long-description",
245-
description: "x".repeat(161),
246-
content: "# Long Description\n",
247-
},
248-
],
249-
};
250-
const call = {
251-
type: "toolCall" as const,
252-
id: "call-long-collection-description",
253-
name: "skill_workshop",
254-
arguments: args,
255-
};
256-
expect(validateToolArguments(tool, call)).toEqual(args);
257-
258-
await expect(tool.execute(call.id, args)).rejects.toThrow(
259-
"Skill proposal description is too large (161 bytes, max 160).",
260-
);
261-
await expect(
262-
fs.access(path.join(workspaceDir, "skills", "long-description", "SKILL.md")),
263-
).rejects.toThrow();
264-
expect(collectionReconcile).not.toHaveProperty("result");
265-
});
266-
267212
it("evaluates an exact pending draft and exposes the persisted result", async () => {
268213
const workspaceDir = await tempDirs.make("openclaw-skill-workshop-evaluate-");
269214
const tool = createSkillWorkshopTool({ workspaceDir, agentId: "main" });

0 commit comments

Comments
 (0)