39634776a7
- Refactored task API to use 'assignment' field instead of 'args' for per-task instructions, enabling clearer separation between shared context and task-specific work. - Introduced structured context/assignment separation pattern with '<swarm_context>' wrapper for template rendering, replacing placeholder-based substitution. - Changed agent frontmatter field from 'thinkingLevel' to 'thinking-level' (kebab-case) for consistency with YAML conventions. - Removed 'context' parameter from ExecutorOptions as context is now prepended at template level rather than executor level. - Removed 'args' field from AgentProgress and SingleResult interfaces, simplifying task result tracking. - Updated task rendering to display full task text instead of formatted args, improving clarity in progress output.
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { renderTemplate } from "@oh-my-pi/pi-coding-agent/task/template";
|
|
|
|
describe("renderTemplate", () => {
|
|
test("returns assignment as task when no context", () => {
|
|
const result = renderTemplate(undefined, {
|
|
id: "Test",
|
|
description: "Short label",
|
|
assignment: "Do the thing in detail.\nStep 1: read file.\nStep 2: edit it.",
|
|
});
|
|
expect(result.task).toBe("Do the thing in detail.\nStep 1: read file.\nStep 2: edit it.");
|
|
expect(result.id).toBe("Test");
|
|
expect(result.description).toBe("Short label");
|
|
});
|
|
|
|
test("prepends context with separator when provided", () => {
|
|
const result = renderTemplate("Shared constraints here", {
|
|
id: "TaskA",
|
|
description: "First task",
|
|
assignment: "Full instructions for the agent.\nWith multiple lines.",
|
|
});
|
|
expect(result.task).toContain("Shared constraints here");
|
|
expect(result.task).toContain("<swarm_context>");
|
|
expect(result.task).toContain("Full instructions for the agent.\nWith multiple lines.");
|
|
});
|
|
|
|
test("trims context whitespace", () => {
|
|
const result = renderTemplate(" \n context \n ", {
|
|
id: "X",
|
|
description: "label",
|
|
assignment: "the real work",
|
|
});
|
|
expect(result.task).toStartWith("<swarm_context>context");
|
|
expect(result.task).toContain("the real work");
|
|
});
|
|
|
|
test("empty context treated as absent", () => {
|
|
const result = renderTemplate(" ", {
|
|
id: "X",
|
|
description: "label",
|
|
assignment: "just the assignment",
|
|
});
|
|
expect(result.task).toBe("just the assignment");
|
|
});
|
|
|
|
test("passes through skills", () => {
|
|
const result = renderTemplate(undefined, {
|
|
id: "X",
|
|
description: "label",
|
|
assignment: "do stuff",
|
|
skills: ["react", "postgres"],
|
|
});
|
|
expect(result.skills).toEqual(["react", "postgres"]);
|
|
});
|
|
});
|