feat(FN-3076): add automatic completion documentation mode for tasks

Merged FN-3076 introducing an auto completion-doc mode that automates task completion documentation. The feature adds a new setting to the settings schema and types, surfaces it in the dashboard Settings UI, provides triage-stage guidance to suggest completion documentation, and is documented in the

Fusion-Task-Id: FN-3076
This commit is contained in:
Fusion
2026-05-02 07:34:34 -07:00
committed by gsxdsm
parent 1c47f91ddd
commit 7a979c0c26
11 changed files with 185 additions and 1 deletions

View File

@@ -159,6 +159,70 @@ describe("buildSpecificationPrompt", () => {
expect(prompt).toContain("pnpm build");
});
describe("completionDocumentationMode setting", () => {
it("omits completion documentation guidance when mode is off", () => {
const settings: Settings = {
maxConcurrent: 2,
maxWorktrees: 4,
pollIntervalMs: 10000,
groupOverlappingFiles: false,
autoMerge: true,
completionDocumentationMode: "off",
};
const prompt = buildSpecificationPrompt(
baseTask,
".fusion/tasks/KB-001/PROMPT.md",
settings,
);
expect(prompt).not.toContain("## Completion Documentation Preference");
});
it("includes changeset guidance when mode is changeset", () => {
const settings: Settings = {
maxConcurrent: 2,
maxWorktrees: 4,
pollIntervalMs: 10000,
groupOverlappingFiles: false,
autoMerge: true,
completionDocumentationMode: "changeset",
};
const prompt = buildSpecificationPrompt(
baseTask,
".fusion/tasks/KB-001/PROMPT.md",
settings,
);
expect(prompt).toContain("## Completion Documentation Preference");
expect(prompt).toContain("`completionDocumentationMode` is set to `changeset`");
expect(prompt).toContain("`.changeset/*.md`");
expect(prompt).toContain("completion documentation/delivery expectations");
});
it("includes changelog guidance when mode is changelog", () => {
const settings: Settings = {
maxConcurrent: 2,
maxWorktrees: 4,
pollIntervalMs: 10000,
groupOverlappingFiles: false,
autoMerge: true,
completionDocumentationMode: "changelog",
};
const prompt = buildSpecificationPrompt(
baseTask,
".fusion/tasks/KB-001/PROMPT.md",
settings,
);
expect(prompt).toContain("`completionDocumentationMode` is set to `changelog`");
expect(prompt).toContain("updating an existing changelog file");
expect(prompt).toContain("do not invent a new changelog file");
});
});
it("generates revision prompt when existingPrompt and feedback provided", () => {
const existingPrompt = "# Original Spec\n\nOriginal content.";
const feedback = "Add more details about error handling";

View File

@@ -2129,6 +2129,18 @@ export function buildSpecificationPrompt(
commandsSection = "\n\n" + lines.join("\n");
}
const completionDocumentationMode = settings?.completionDocumentationMode ?? "off";
let completionDocumentationSection = "";
if (completionDocumentationMode !== "off") {
const instruction = completionDocumentationMode === "changeset"
? "If the task changes published-package behavior, require a `.changeset/*.md` entry and call out the repository's changeset workflow."
: "Require updating an existing changelog file as part of completion; do not invent a new changelog file when none exists.";
completionDocumentationSection = `\n\n## Completion Documentation Preference\nProject setting \`completionDocumentationMode\` is set to \`${completionDocumentationMode}\`.
When writing PROMPT.md, add this as an explicit requirement under completion documentation/delivery expectations (not a side note):
- ${instruction}`;
}
// Build project memory section from settings.
// When enabled, agents consult project memory for durable project learnings.
// Backend-aware: instructions branch based on memoryBackendType (file, readonly, qmd)
@@ -2277,5 +2289,5 @@ ${task.dependencies.length > 0 ? `- **Dependencies:** ${task.dependencies.join("
## Instructions
${isRevision ? "1. Review the existing specification and user feedback carefully\n2. Revise the PROMPT.md to address the feedback while maintaining the structure\n3. Ensure the specification is detailed enough for an AI agent to execute" : isFreshRespecification ? "1. Read the project structure to understand context (package.json, source files, etc.)\n2. Write a fresh complete PROMPT.md specification to the given path following the format in your system prompt\n3. Address the user feedback without carrying forward stale assumptions from the old spec\n4. Name actual files, functions, and patterns from the codebase — be specific" : "1. Read the project structure to understand context (package.json, source files, etc.)\n2. Write a complete PROMPT.md specification to the given path following the format in your system prompt\n3. The specification must be detailed enough for an autonomous AI agent to implement without asking questions\n4. Name actual files, functions, and patterns from the codebase — be specific"}
Use the write tool to write the specification file.${commandsSection}${memorySection}${attachmentsSection}${userCommentsSection}`;
Use the write tool to write the specification file.${commandsSection}${completionDocumentationSection}${memorySection}${attachmentsSection}${userCommentsSection}`;
}