address review: move CLI reference to workflow-util, inline in prompt

- Move generateCliReference() to @uncaged/workflow-util
- buildRolePrompt inlines CLI reference directly (no agent tool call)
- Fix Role terminology to use new field names
- Add maintenance comment in cli-reference.ts
- Fix test assertions
This commit is contained in:
2026-05-22 03:29:01 +00:00
parent 866154ad73
commit 995f273fa5
5 changed files with 83 additions and 85 deletions
@@ -19,7 +19,7 @@ describe("buildRolePrompt", () => {
expect(result).toContain("- cursor-agent");
expect(result).toContain("- file-edit");
expect(result).toContain("## Prepare");
expect(result).toContain("uwf skill cli");
expect(result).toContain("uwf CLI Reference");
expect(result).toContain("cursor-agent, file-edit");
expect(result).toContain("## Procedure");
expect(result).toContain("Implement the feature.");
@@ -39,7 +39,7 @@ describe("buildRolePrompt", () => {
const result = buildRolePrompt(role);
expect(result).toContain("## Goal");
expect(result).toContain("## Prepare");
expect(result).toContain("uwf skill cli");
expect(result).toContain("uwf CLI Reference");
expect(result).toContain("## Procedure");
expect(result).not.toContain("## Capabilities");
expect(result).not.toContain("## Output");
@@ -56,7 +56,7 @@ describe("buildRolePrompt", () => {
};
const result = buildRolePrompt(role);
expect(result).toContain("## Prepare");
expect(result).toContain("uwf skill cli");
expect(result).toContain("uwf CLI Reference");
expect(result).not.toContain("## Goal");
expect(result).not.toContain("## Capabilities");
expect(result).not.toContain("## Procedure");
@@ -1,4 +1,5 @@
import type { RoleDefinition } from "@uncaged/workflow-protocol";
import { generateCliReference } from "@uncaged/workflow-util";
/**
* Build the role prompt from a RoleDefinition.
@@ -6,9 +7,9 @@ import type { RoleDefinition } from "@uncaged/workflow-protocol";
* Assembles structured sections: Goal, Capabilities, Prepare, Procedure, Output.
* Empty strings and empty arrays are omitted from the output.
*
* The Prepare section always instructs the agent to run `uwf skill cli` to load
* workflow knowledge, plus renders the capabilities array as keyword hints for
* implicit skill loading.
* The Prepare section always inlines the uwf CLI reference so the agent has
* workflow knowledge without needing to run an external command. The capabilities
* array is rendered as keyword hints for implicit skill loading.
*/
export function buildRolePrompt(role: RoleDefinition): string {
const sections: string[] = [];
@@ -22,21 +23,14 @@ export function buildRolePrompt(role: RoleDefinition): string {
sections.push(`## Capabilities\n\n${list}`);
}
const prepareLines: string[] = [
"Run the following command to load workflow CLI knowledge before starting work:",
"",
"```",
"uwf skill cli",
"```",
];
const prepareLines: string[] = [generateCliReference()];
if (role.capabilities.length > 0) {
const keywords = role.capabilities.join(", ");
prepareLines.push(
"",
`You have the following capabilities: ${keywords}. Load relevant skills matching these keywords before starting work.`,
);
}
sections.push(`## Prepare\n\n${prepareLines.join("\n")}`);
sections.push(`## Prepare\n\n${prepareLines.join("\n\n")}`);
if (role.procedure !== "") {
sections.push(`## Procedure\n\n${role.procedure}`);