refactor(agent): rename resource formatting helpers
This commit is contained in:
@@ -3,7 +3,7 @@ import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { NodeExecutionEnv } from "../../src/harness/execution-env.js";
|
||||
import {
|
||||
expandPromptTemplate,
|
||||
formatPromptTemplateInvocation,
|
||||
loadPromptTemplates,
|
||||
loadSourcedPromptTemplates,
|
||||
} from "../../src/harness/prompt-templates.js";
|
||||
@@ -80,10 +80,10 @@ describe("loadPromptTemplates", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("expandPromptTemplate", () => {
|
||||
describe("formatPromptTemplateInvocation", () => {
|
||||
it("substitutes command arguments", () => {
|
||||
const content = "$1 $" + "{@:2} $ARGUMENTS";
|
||||
expect(expandPromptTemplate({ name: "one", content }, ["hello world", "test"])).toBe(
|
||||
expect(formatPromptTemplateInvocation({ name: "one", content }, ["hello world", "test"])).toBe(
|
||||
"hello world test hello world test",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { expandPromptTemplate } from "../../src/harness/prompt-templates.js";
|
||||
import { expandSkillCommand } from "../../src/harness/skills.js";
|
||||
import { formatPromptTemplateInvocation } from "../../src/harness/prompt-templates.js";
|
||||
import { formatSkillInvocation } from "../../src/harness/skills.js";
|
||||
|
||||
describe("resource expansion helpers", () => {
|
||||
it("expands skills with additional instructions", () => {
|
||||
describe("resource formatting helpers", () => {
|
||||
it("formats skill invocations with additional instructions", () => {
|
||||
const skill = {
|
||||
name: "inspect",
|
||||
description: "Inspect things",
|
||||
@@ -11,14 +11,14 @@ describe("resource expansion helpers", () => {
|
||||
filePath: "/project/.pi/skills/inspect/SKILL.md",
|
||||
};
|
||||
|
||||
expect(expandSkillCommand(skill, "Check errors.")).toBe(
|
||||
expect(formatSkillInvocation(skill, "Check errors.")).toBe(
|
||||
'<skill name="inspect" location="/project/.pi/skills/inspect/SKILL.md">\nReferences are relative to /project/.pi/skills/inspect.\n\nUse inspection tools.\n</skill>\n\nCheck errors.',
|
||||
);
|
||||
});
|
||||
|
||||
it("expands prompt templates with positional arguments", () => {
|
||||
expect(expandPromptTemplate({ name: "review", content: "Review $1 with $ARGUMENTS" }, ["a.ts", "care"])).toBe(
|
||||
"Review a.ts with a.ts care",
|
||||
);
|
||||
it("formats prompt template invocations with positional arguments", () => {
|
||||
expect(
|
||||
formatPromptTemplateInvocation({ name: "review", content: "Review $1 with $ARGUMENTS" }, ["a.ts", "care"]),
|
||||
).toBe("Review a.ts with a.ts care");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user