Files
oh-my-pi/packages/coding-agent/src/task/template.ts
T
can1357 a1be87ad9b feat(coding-agent/task): added optional assignment field to track raw task text separately from templates
- Added optional `assignment` field to task result and progress interfaces to track raw per-task assignment text separately from full templated task.
- Updated task rendering to display assignment text instead of full task template when available, improving clarity of task display.
- Modified task section rendering to show trimmed assignment text with fallback to task field if assignment is not available.
- Propagated assignment field through task executor, template renderer, and result objects to maintain consistency across task processing pipeline.
2026-03-11 01:11:20 +01:00

34 lines
1.0 KiB
TypeScript

import { renderPromptTemplate } from "../config/prompt-templates";
import subagentUserPromptTemplate from "../prompts/system/subagent-user-prompt.md" with { type: "text" };
import type { TaskItem } from "./types";
interface RenderResult {
/** Full task text sent to the subagent */
task: string;
/** Raw per-task assignment text, without prompt template boilerplate */
assignment: string;
id: string;
description: string;
}
/**
* Build the full task text from shared context and per-task assignment.
*
* If context is provided, it is prepended with a separator.
*/
export function renderTemplate(context: string | undefined, task: TaskItem): RenderResult {
let { id, description, assignment } = task;
assignment = assignment.trim();
context = context?.trim();
if (!context || !assignment) {
return { task: assignment || context!, assignment: assignment || context!, id, description };
}
return {
task: renderPromptTemplate(subagentUserPromptTemplate, { context, assignment }),
assignment,
id,
description,
};
}