Files
oh-my-pi/packages/coding-agent/src/task/template.ts
T
can1357 39634776a7 feat(coding-agent): refactored task API to use 'assignment' field and structured context separation
- 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.
2026-02-05 07:43:53 +01:00

33 lines
942 B
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;
id: string;
description: string;
skills?: 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, skills } = task;
assignment = assignment.trim();
context = context?.trim();
if (!context || !assignment) {
return { task: assignment || context!, id, description, skills };
}
return {
task: renderPromptTemplate(subagentUserPromptTemplate, { context, assignment }),
id,
description,
skills,
};
}