Browse Source

fix: address PR review comments - remove stale state.summary reference and rewriteInterviewDocument

Alvin Real 3 months ago
parent
commit
b08688c39e
3 changed files with 46 additions and 12 deletions
  1. 0 9
      src/interview/document.ts
  2. 42 0
      src/interview/interview.test.ts
  3. 4 3
      src/interview/service.ts

+ 0 - 9
src/interview/document.ts

@@ -208,15 +208,6 @@ export async function readInterviewDocument(
   return fs.readFile(record.markdownPath, 'utf8');
 }
 
-export async function rewriteInterviewDocument(
-  record: InterviewRecord,
-  _questions: InterviewQuestion[],
-): Promise<string> {
-  // For now, just return the existing document as-is
-  // The document is updated via appendInterviewAnswers when answers are submitted
-  return readInterviewDocument(record);
-}
-
 export async function appendInterviewAnswers(
   record: InterviewRecord,
   questions: InterviewQuestion[],

+ 42 - 0
src/interview/interview.test.ts

@@ -844,6 +844,48 @@ describe("interview service", () => {
 
       await fs.rm(tempDir, { recursive: true, force: true });
     });
+
+    test("more-questions nudge uses the current interview document", async () => {
+      const tempDir = await fs.mkdtemp("/tmp/interview-test-");
+      const ctx = createMockContext({ directory: tempDir });
+
+      const service = createInterviewService(ctx);
+      service.setBaseUrlResolver(async () => "http://localhost:9999");
+      const output = { parts: [] as Array<{ type: string; text?: string }> };
+
+      await service.handleCommandExecuteBefore(
+        {
+          command: "interview",
+          sessionID: "session-nudge-doc",
+          arguments: "Prompt Document Test",
+        },
+        output
+      );
+
+      const interviewId = requireInterviewId(
+        extractInterviewIdFromLastPrompt(ctx.client.session.prompt)
+      );
+      const interviewPath = path.join(
+        tempDir,
+        "interview",
+        "prompt-document-test.md"
+      );
+      await fs.writeFile(
+        interviewPath,
+        "# Prompt Document Test\n\n## Current spec\n\nExisting spec content.\n",
+        "utf8"
+      );
+
+      ctx.client.session.promptAsync.mock.calls.length = 0;
+      await service.handleNudgeAction(interviewId, "more-questions");
+
+      const promptText = getPromptTexts(ctx.client.session.promptAsync)[0] ?? "";
+      expect(promptText).toContain("Current interview document:");
+      expect(promptText).toContain("Existing spec content.");
+      expect(promptText).not.toContain("undefined");
+
+      await fs.rm(tempDir, { recursive: true, force: true });
+    });
   });
 
   describe("configurable output folder", () => {

+ 4 - 3
src/interview/service.ts

@@ -19,7 +19,6 @@ import {
   readInterviewDocument,
   relativeInterviewPath,
   resolveExistingInterviewPath,
-  rewriteInterviewDocument,
   slugify,
 } from './document';
 import { buildFallbackState, findLatestAssistantState } from './parser';
@@ -308,7 +307,7 @@ export function createInterviewService(
     const fallbackState = buildFallbackState(interviewMessages);
     const state = parsed.state ?? fallbackState;
 
-    const document = await rewriteInterviewDocument(interview, state.questions);
+    const document = await readInterviewDocument(interview);
 
     const interviewState: InterviewState = {
       interview,
@@ -685,7 +684,9 @@ export function createInterviewService(
         prompt = [
           `The user reviewed the completed interview spec and wants you to continue.`,
           ``,
-          `Current spec summary: ${state.summary}`,
+          `Current interview document:`,
+          ``,
+          state.document,
           ``,
           `Ask up to ${maxQuestions} new clarifying questions about aspects that are still unclear or underspecified.`,
           ``,