prompts.ts
2,506 bytes
| 1 | import type { Segment } from '../../shared/types' |
|---|---|
| 2 | import type { SpecPackFile } from '../providers/types' |
| 3 | |
| 4 | function renderTranscript(segments: Segment[]): string { |
| 5 | return segments.map((segment) => `[${segment.id}] ${segment.speaker}: ${segment.text}`).join('\n') |
| 6 | } |
| 7 | |
| 8 | export function buildGeneratePrompt(file: SpecPackFile, projectName: string, segments: Segment[]): string { |
| 9 | const transcript = renderTranscript(segments) |
| 10 | const header = `You are writing ${file} for a project called "${projectName}", based on a transcript of a Socratic spec interview with its developer. Write only what the transcript supports; do not invent requirements. Output English Markdown only, no commentary.` |
| 11 | |
| 12 | switch (file) { |
| 13 | case 'SPEC.md': |
| 14 | return [ |
| 15 | header, |
| 16 | 'Mirror the structure of a typical SPEC.md: Goal, Users, User stories, Functional requirements (FR-001, FR-002, ...), Edge cases, Out of scope, Assumptions.', |
| 17 | 'Every functional requirement line MUST end with one or more provenance markers, e.g. "[S3]" or "[S5][S9]", citing the transcript segment ids that justify it.', |
| 18 | '', |
| 19 | 'Transcript:', |
| 20 | transcript, |
| 21 | ].join('\n') |
| 22 | |
| 23 | case 'PLAN.md': |
| 24 | return [ |
| 25 | header, |
| 26 | 'Mirror the structure of a typical PLAN.md: Stack, Layout, key interfaces, API routes, and decisions already made, all derived from the transcript.', |
| 27 | '', |
| 28 | 'Transcript:', |
| 29 | transcript, |
| 30 | ].join('\n') |
| 31 | |
| 32 | case 'TASKS.md': |
| 33 | return [ |
| 34 | header, |
| 35 | 'Mirror the structure of a typical TASKS.md: an ordered checklist of implementation tasks, each with a Depends line and a Verify line.', |
| 36 | 'Every task MUST include at least one concrete verification command (e.g. `npm test`).', |
| 37 | '', |
| 38 | 'Transcript:', |
| 39 | transcript, |
| 40 | ].join('\n') |
| 41 | |
| 42 | case 'VERIFICATION.md': |
| 43 | return [ |
| 44 | header, |
| 45 | 'Describe what "done" looks like for this project and how a coding agent should verify it (commands to run, behaviors to check).', |
| 46 | '', |
| 47 | 'Transcript:', |
| 48 | transcript, |
| 49 | ].join('\n') |
| 50 | |
| 51 | case 'HANDOFF.md': |
| 52 | return [ |
| 53 | header, |
| 54 | 'Explain how to hand this spec pack to a sandboxed Claude Code session.', |
| 55 | 'It MUST include a ready-to-copy shell command line that launches such a session against this spec pack, using the `claude` CLI, e.g.: `claude "Work through spec/TASKS.md in order."`', |
| 56 | '', |
| 57 | 'Transcript:', |
| 58 | transcript, |
| 59 | ].join('\n') |
| 60 | } |
| 61 | } |
| 62 | |