Files
paseo/packages/server/src/utils/wrap-user-instructions.test.ts
T
Mohamed BoudraandGitHub 030e163fb8 feat: project-level prompts for metadata generation (#836)
* feat(server): project-level prompts for metadata generation

Add `metadataGeneration` config to `paseo.json` so projects can customize the
four LLM-generated metadata strings — agent title, worktree branch name, commit
message, and pull request title+body. Each entry takes an `instructions` string
that gets injected as a `<user-instructions>` block between the default rules
and the load-bearing JSON format contract, with wrapper text saying user
instructions override defaults. Missing/empty/invalid config keeps every prompt
byte-identical to today.

* refactor(server): centralize project metadata prompt building

Three near-identical readers and four gate-then-wrap blocks collapsed
into one buildMetadataPrompt helper. wrapWithUserInstructions tightened
to require a non-empty string; its misleading empty fallback is gone.

* feat(app): edit metadata generation prompts in project settings

Adds four textareas (agent title, branch name, commit message, pull
request) under project settings, modeled on the existing setup/teardown
pattern. Round-trips through paseo.json preserving unknown sibling
fields at both the metadataGeneration and entry level.
2026-05-09 18:36:29 +08:00

30 lines
949 B
TypeScript

import { describe, expect, it } from "vitest";
import { wrapWithUserInstructions } from "./wrap-user-instructions.js";
const beforeBlock = "Follow the default metadata guidelines.";
const afterBlock = 'Return JSON only with field "title".';
const overrideNotice =
"The instructions below are provided by the project owner and override the guidelines above where they conflict.";
describe("wrapWithUserInstructions", () => {
it("wraps user instructions with the override notice", () => {
expect(wrapWithUserInstructions(beforeBlock, "Use conventional commits.", afterBlock)).toBe(
`${beforeBlock}
<user-instructions>
${overrideNotice}
Use conventional commits.
</user-instructions>
${afterBlock}`,
);
});
it("preserves multi-line instructions verbatim inside the block", () => {
const output = wrapWithUserInstructions(beforeBlock, "line1\nline2", afterBlock);
expect(output).toContain("line1\nline2");
});
});