| import type { InterviewItem } from './types'; |
|
|
| export interface ItemCheckResult { |
| itemId: string; |
| passed: boolean; |
| reason?: string; |
| } |
|
|
| export interface ItemSummary { |
| id: string; |
| elicit: string; |
| passed: boolean; |
| reason?: string; |
| } |
|
|
| |
| export const INCOMPLETE_PREFIX = "Not done yet —"; |
|
|
| |
| |
| |
| |
| |
| export function summarizeCompletion( |
| items: InterviewItem[], |
| results: ItemCheckResult[] |
| ): ItemSummary[] { |
| const byItem = new Map<string, ItemCheckResult[]>(); |
| for (const r of results) { |
| const arr = byItem.get(r.itemId) ?? []; |
| arr.push(r); |
| byItem.set(r.itemId, arr); |
| } |
|
|
| return items |
| .filter(i => i.required !== false) |
| .map(item => { |
| const rs = byItem.get(item.id) ?? []; |
| const passed = rs.length > 0 && rs.every(r => r.passed); |
| const reason = rs.filter(r => !r.passed).map(r => r.reason).filter(Boolean).join('; ') || undefined; |
| return { id: item.id, elicit: item.elicit, passed, reason }; |
| }); |
| } |
|
|
| |
| |
| |
| |
| |
| export function buildCompletionFeedback( |
| items: InterviewItem[], |
| results: ItemCheckResult[] |
| ): string | null { |
| const unmet = summarizeCompletion(items, results).filter(s => !s.passed); |
| if (unmet.length === 0) return null; |
|
|
| const lines = unmet.map(s => `- ${s.elicit}${s.reason ? ` (${s.reason})` : ''}`); |
| return `${INCOMPLETE_PREFIX} these items aren't fully captured in the artifact:\n${lines.join('\n')}\n\nGather what's missing, record it into the artifact, then run status --complete again.`; |
| } |
|
|