diff --git a/.changeset/fn-7593-before-after-top.md b/.changeset/fn-7593-before-after-top.md new file mode 100644 index 0000000000..43186a0490 --- /dev/null +++ b/.changeset/fn-7593-before-after-top.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Move the Before → After transformation summary to the top of generated task definitions. +category: fix +dev: Reorders the standard and fast triage `PROMPT.md` templates in packages/core/src/agent-prompts.ts so `## Before → After Transformation` is the first content section, ahead of `## Review Level` and `## Mission`, matching FN-7499's glance-verification intent. diff --git a/docs/task-management.md b/docs/task-management.md index f592e41fe2..11ea9b8497 100644 --- a/docs/task-management.md +++ b/docs/task-management.md @@ -552,8 +552,8 @@ The task detail modal exposes multiple tabs: After planning, each task gets a structured `PROMPT.md` with sections like: -- Mission - Before → after transformation summary +- Mission - Dependencies - Context to read first - File scope diff --git a/packages/core/src/__tests__/agent-prompts.test.ts b/packages/core/src/__tests__/agent-prompts.test.ts index 1f625b0f64..a34837b925 100644 --- a/packages/core/src/__tests__/agent-prompts.test.ts +++ b/packages/core/src/__tests__/agent-prompts.test.ts @@ -312,6 +312,26 @@ describe("resolveAgentPrompt", () => { } }); + it("places the Before → After Transformation section at the top of the definition, ahead of Mission and Review Level (FN-7593)", () => { + const standardPrompt = resolveAgentPrompt("triage"); + const fastPrompt = builtinSeamPrompt("planning-fast"); + + const standardTransformationIdx = standardPrompt.indexOf("## Before → After Transformation"); + const standardReviewLevelIdx = standardPrompt.indexOf("## Review Level"); + const standardMissionIdx = standardPrompt.indexOf("## Mission"); + expect(standardTransformationIdx).toBeGreaterThan(-1); + expect(standardReviewLevelIdx).toBeGreaterThan(-1); + expect(standardMissionIdx).toBeGreaterThan(-1); + expect(standardTransformationIdx).toBeLessThan(standardReviewLevelIdx); + expect(standardTransformationIdx).toBeLessThan(standardMissionIdx); + + const fastTransformationIdx = fastPrompt.indexOf("## Before → After Transformation"); + const fastMissionIdx = fastPrompt.indexOf("## Mission"); + expect(fastTransformationIdx).toBeGreaterThan(-1); + expect(fastMissionIdx).toBeGreaterThan(-1); + expect(fastTransformationIdx).toBeLessThan(fastMissionIdx); + }); + it("triage planning prompt is sourced from workflow IR without an engine duplicate", () => { const corePrompt = resolveAgentPrompt("triage"); const planningPrompt = resolvePlanningPromptFromIr(BUILTIN_CODING_WORKFLOW_IR); diff --git a/packages/core/src/agent-prompts.ts b/packages/core/src/agent-prompts.ts index 39d75641a9..14014c0046 100644 --- a/packages/core/src/agent-prompts.ts +++ b/packages/core/src/agent-prompts.ts @@ -221,6 +221,9 @@ Keep the prompt lean, but preserve mandatory planning contracts: duplicate searc FNXC:FastPlanning 2026-07-04-16:25: Fast mode skips heavyweight planning ceremony, but every generated task still needs the same glanceable Before → After Transformation section as standard planning so operators can validate intent quickly. + +FNXC:FastPlanning 2026-07-05-12:00: +Per FN-7593, the transformation summary must sit at the top of the PROMPT.md (before Mission), matching the standard-mode placement, so operators get the same glance-first ordering in fast mode. */ const FAST_TRIAGE_PROMPT_TEXT = `You are a task specification agent for "fn". This task is running in **fast mode**. @@ -235,7 +238,7 @@ Write a lean, executable PROMPT.md quickly. Preserve safety gates, but skip heav Before writing a spec, call \`fn_task_list\` for active work, then call \`fn_task_search\` with 2-4 targeted keyword phrases from the title/description, such as file paths, symptoms, and symbols. For any likely match in \`done\` or \`archived\`, call \`fn_task_show\` and inspect it before deciding. If an existing task covers the same work, do not write PROMPT.md; write exactly \`DUPLICATE: {existing-task-id}\`. ## Required PROMPT.md shape -Write PROMPT.md with Mission, Before → After Transformation, Dependencies, Context to Read First, File Scope, Steps, Documentation Requirements, Completion Criteria, Git Commit Convention, and Do NOT. Include \`## Before → After Transformation\` after Mission with concise Before and After bullets stating current state, target state, and why it satisfies the user's request at a glance. In \`## Steps\`, every executable heading MUST use \`### Step N: \` (for example, \`### Step 1: Preflight\`); Do not write bare \`### Preflight\` / \`### Implementation\` headings. Do not add review-level, triage subtask, or proactive subtask headings. +Write PROMPT.md with Before → After Transformation, Mission, Dependencies, Context to Read First, File Scope, Steps, Documentation Requirements, Completion Criteria, Git Commit Convention, and Do NOT. Put \`## Before → After Transformation\` at the top, before \`## Mission\`, with concise Before/After bullets: current state, target state, why it satisfies the user's request at a glance. In \`## Steps\`, every executable heading MUST use \`### Step N: \` (e.g. \`### Step 1: Preflight\`). Do not write bare \`### Preflight\` / \`### Implementation\` headings, and do not add review-level, triage subtask, or proactive subtask headings. ## Surface Enumeration For bug fixes and UI-affordance add/remove tasks, the spec MUST include a \`## Surface Enumeration\` section. The workflow Plan Review gate validates this before execution when plan review is enabled. @@ -297,6 +300,11 @@ Follow this structure exactly: **Created:** {YYYY-MM-DD} **Size:** {S | M | L} +## Before → After Transformation + +- **Before:** {Briefly describe the current state, missing capability, broken behavior, or operator pain point} +- **After:** {Briefly describe the target state and how it satisfies the user's request at a glance} + ## Review Level: {0-3} ({None | Plan Only | Plan and Code | Full}) **Assessment:** {1-2 sentences explaining the score} @@ -306,11 +314,6 @@ Follow this structure exactly: {One paragraph: what you're building and why it matters} -## Before → After Transformation - -- **Before:** {Briefly describe the current state, missing capability, broken behavior, or operator pain point} -- **After:** {Briefly describe the target state and how it satisfies the user's request at a glance} - ## Surface Enumeration {Required for bug-fix tasks and UI-affordance add/remove tasks (adding, removing, or restructuring icons, buttons, chevrons/arrows, toggles, badges, menu entries, click targets): a checklist enumerating every surface the fixed invariant must hold across. Include every provider/bridge for streaming and agent paths; desktop AND mobile breakpoints; empty/undefined/duplicate/populated data states; and every hook/component/module that shares the affected logic. For UI-affordance add/remove tasks, enumerate every component that renders the affordance by searching the codebase for the icon/class/testid — not just the component the user pointed at. Explicitly check for leftover shells after removal (empty buttons, orphaned click targets, now-unused wrappers, dangling aria-labels) across both desktop and mobile breakpoints. Use the canonical checklist in docs/testing.md as the starting point.} @@ -437,11 +440,14 @@ If this task REMOVES existing functionality (deleting modules, settings, API end ## Transformation summary requirement -Every normal implementation, documentation, or decision task definition MUST include \`## Before → After Transformation\` after \`## Mission\`. Keep it concise: use brief Before and After bullets (or equivalent short prose) that name the current state, the target state, and why that target satisfies the user's request at a glance. +Every normal implementation, documentation, or decision task definition MUST include \`## Before → After Transformation\` at the top of the definition, immediately after the \`# Task\` title and \`Created\`/\`Size\` metadata, before \`## Review Level\` and \`## Mission\`. Keep it concise: use brief Before and After bullets (or equivalent short prose) that name the current state, the target state, and why that target satisfies the user's request at a glance. ## Testing requirements diff --git a/packages/engine/src/__tests__/triage.test.ts b/packages/engine/src/__tests__/triage.test.ts index e497d912b1..506bab4734 100644 --- a/packages/engine/src/__tests__/triage.test.ts +++ b/packages/engine/src/__tests__/triage.test.ts @@ -753,6 +753,23 @@ describe("FN-5893 invariant regression wording", () => { expect(FAST_PLANNING_PROMPT).not.toContain("## Proactive Subtask Breakdown"); }); + it("places Before → After Transformation at the top of the definition, ahead of Mission and Review Level (FN-7593)", () => { + const standardTransformationIdx = STANDARD_PLANNING_PROMPT.indexOf("## Before → After Transformation"); + const standardReviewLevelIdx = STANDARD_PLANNING_PROMPT.indexOf("## Review Level"); + const standardMissionIdx = STANDARD_PLANNING_PROMPT.indexOf("## Mission"); + expect(standardTransformationIdx).toBeGreaterThan(-1); + expect(standardReviewLevelIdx).toBeGreaterThan(-1); + expect(standardMissionIdx).toBeGreaterThan(-1); + expect(standardTransformationIdx).toBeLessThan(standardReviewLevelIdx); + expect(standardTransformationIdx).toBeLessThan(standardMissionIdx); + + const fastTransformationIdx = FAST_PLANNING_PROMPT.indexOf("## Before → After Transformation"); + const fastMissionIdx = FAST_PLANNING_PROMPT.indexOf("## Mission"); + expect(fastTransformationIdx).toBeGreaterThan(-1); + expect(fastMissionIdx).toBeGreaterThan(-1); + expect(fastTransformationIdx).toBeLessThan(fastMissionIdx); + }); + it("requires invariant-level regression coverage in standard, fast, and core triage prompts", () => { for (const prompt of [ TRIAGE_POLICY_PROMPT,