User task chat and steering comments now flow into planning, review, and merge agent context. - Add a shared user-comment formatter and selector for prompt context. - Inject latest user comments into planner-triggered review, reviewer, merger, and clean-room AI merge prompts. - Cover comment selection, prompt formatting, review/merge propagation, and docs updates with targeted tests. Files changed: docs/architecture.md | 1 + docs/dashboard-guide.md | 1 + .../src/__tests__/agent-user-comments.test.ts | 81 ++++++++++++++++++++++ .../executor-review-step-indexing.test.ts | 28 +++++++- packages/engine/src/__tests__/merger-ai.test.ts | 54 +++++++++++++++ .../src/__tests__/merger-prompt-and-utils.test.ts | 29 ++++++++ packages/engine/src/__tests__/reviewer.test.ts | 37 ++++++++-- packages/engine/src/__tests__/triage.test.ts | 23 ++++++ packages/engine/src/agent-user-comments.ts | 60 ++++++++++++++++ packages/engine/src/executor.ts | 14 ++-- packages/engine/src/merger-ai.ts | 23 +++++- packages/engine/src/merger.ts | 22 +++++- packages/engine/src/reviewer.ts | 13 ++++ 13 files changed, 372 insertions(+), 14 deletions(-) Fusion-Task-Id: FN-6915 Fusion-Task-Lineage: 02de0c12-481a-4489-b495-70c9c00619bc
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import type { TaskComment } from "@fusion/core";
|
|
|
|
const DEFAULT_USER_COMMENT_LIMIT = 20;
|
|
|
|
function commentTimestamp(comment: TaskComment): string {
|
|
return comment.updatedAt || comment.createdAt;
|
|
}
|
|
|
|
function timestampMs(comment: TaskComment): number {
|
|
const parsed = Date.parse(commentTimestamp(comment));
|
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
}
|
|
|
|
function quoteCommentText(text: string): string[] {
|
|
const normalized = text.trim();
|
|
if (!normalized) return ["> (empty comment)"];
|
|
return normalized.split(/\r?\n/).map((line) => `> ${line}`);
|
|
}
|
|
|
|
/**
|
|
* FNXC:AgentSteering 2026-06-22-00:05:
|
|
* Task-detail chat and user comments must reach every agent lane that builds prompts: executor, merger, reviewer, and planner. This helper is the canonical formatter for next-prompt delivery outside the executor's live steering injection path, so merger and reviewer prompts do not drift or duplicate comment logic.
|
|
*/
|
|
export function selectUserCommentsForAgentContext(
|
|
task: { comments?: TaskComment[] },
|
|
opts: { limit?: number } = {},
|
|
): TaskComment[] {
|
|
const limit = opts.limit ?? DEFAULT_USER_COMMENT_LIMIT;
|
|
if (!task.comments || task.comments.length === 0 || limit <= 0) return [];
|
|
|
|
const byId = new Map<string, TaskComment>();
|
|
for (const comment of task.comments) {
|
|
if (comment.author !== "user") continue;
|
|
byId.set(comment.id, comment);
|
|
}
|
|
|
|
return [...byId.values()]
|
|
.sort((a, b) => timestampMs(a) - timestampMs(b))
|
|
.slice(-limit);
|
|
}
|
|
|
|
export function buildUserCommentsPromptSection(
|
|
comments: TaskComment[],
|
|
opts: { heading?: string; intro?: string } = {},
|
|
): string {
|
|
if (comments.length === 0) return "";
|
|
|
|
const heading = opts.heading ?? "## User Comments";
|
|
const intro = opts.intro ?? "The following user comments were posted on this task. Consider and address this user feedback when completing your agent pass.";
|
|
const lines = [heading, "", intro, ""];
|
|
|
|
for (const comment of comments) {
|
|
const timestamp = commentTimestamp(comment);
|
|
lines.push(`**${comment.author}** — ${timestamp}`);
|
|
lines.push(...quoteCommentText(comment.text));
|
|
lines.push("");
|
|
}
|
|
|
|
return lines.join("\n").trimEnd();
|
|
}
|