feat(FN-1048): add configurable agent prompts with built-in templates

- Add AgentPromptTemplate and AgentPromptsConfig types to ProjectSettings
- Create agent-prompts module with 7 built-in prompt templates and role resolver
- Wire engine agents (executor, reviewer, merger, triage) to use resolved prompts
- Add 25 test cases covering template resolution, role assignment, and validation
- Export new types from @fusion/core package
- Document agentPrompts configuration and built-in templates in AGENTS.md
This commit is contained in:
gsxdsm
2026-04-07 12:31:28 -07:00
parent 8d6a44d1b6
commit 5646a03d83
9 changed files with 1231 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ import { join } from "node:path";
import { existsSync } from "node:fs";
import type { TaskStore, Task, TaskDetail, StepStatus, Settings, WorkflowStep, MissionStore, Slice, AgentState, AgentCapability } from "@fusion/core";
import type { AgentStore } from "@fusion/core";
import { buildExecutionMemoryInstructions } from "@fusion/core";
import { buildExecutionMemoryInstructions, resolveAgentPrompt } from "@fusion/core";
import { findWorktreeUser } from "./merger.js";
import { generateWorktreeName, slugify } from "./worktree-names.js";
import { Type, type Static } from "@mariozechner/pi-ai";
@@ -216,6 +216,12 @@ Tests and typecheck are also hard quality gates:
- If the repository exposes a typecheck command, run it and keep fixing failures until it passes
- Do not stop at "out of scope" if additional fixes are required to restore green tests, build, or typecheck`;
/** Resolve the executor system prompt from settings, falling back to the hardcoded constant. */
function getExecutorSystemPrompt(settings: Settings): string {
const customPrompt = resolveAgentPrompt("executor", settings.agentPrompts);
return customPrompt || EXECUTOR_SYSTEM_PROMPT;
}
export interface TaskExecutorOptions {
semaphore?: AgentSemaphore;
/** Worktree pool for recycling idle worktrees across tasks. */
@@ -979,7 +985,7 @@ export class TaskExecutor {
let { session, sessionFile } = await createKbAgent({
cwd: worktreePath,
systemPrompt: EXECUTOR_SYSTEM_PROMPT,
systemPrompt: getExecutorSystemPrompt(settings),
tools: "coding",
customTools,
onText: agentLogger.onText,
@@ -1166,7 +1172,7 @@ export class TaskExecutor {
const { session: retrySession, sessionFile: retrySessionFile } = await createKbAgent({
cwd: worktreePath,
systemPrompt: EXECUTOR_SYSTEM_PROMPT,
systemPrompt: getExecutorSystemPrompt(settings),
tools: "coding",
customTools,
onText: agentLogger.onText,
@@ -1744,6 +1750,7 @@ export class TaskExecutor {
validatorFallbackModelId: settings.validatorFallbackModelId,
store,
taskId,
agentPrompts: settings.agentPrompts,
},
);