promptBuilderForPRD returns a function that loads the PRD and builds a prompt with the next story inlined. This is called before each iteration so that newly completed stories are skipped. The returned storyID is stored on the Loop.
(prdPath string)
| 101 | // with the next story inlined. This is called before each iteration so that |
| 102 | // newly completed stories are skipped. The returned storyID is stored on the Loop. |
| 103 | func promptBuilderForPRD(prdPath string) func() (string, string, error) { |
| 104 | return func() (string, string, error) { |
| 105 | p, err := prd.LoadPRD(prdPath) |
| 106 | if err != nil { |
| 107 | return "", "", fmt.Errorf("failed to load PRD for prompt: %w", err) |
| 108 | } |
| 109 | |
| 110 | story := p.NextStory() |
| 111 | if story == nil { |
| 112 | return "", "", fmt.Errorf("all stories are complete") |
| 113 | } |
| 114 | |
| 115 | // Mark the story as in-progress in the markdown file |
| 116 | _ = prd.SetStoryStatus(prdPath, story.ID, "in-progress") |
| 117 | |
| 118 | storyCtx := p.NextStoryContext() |
| 119 | |
| 120 | prompt := embed.GetPrompt(prd.ProgressPath(prdPath), *storyCtx, story.ID, story.Title) |
| 121 | return prompt, story.ID, nil |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | // Events returns the channel for receiving events from the loop. |
| 126 | func (l *Loop) Events() <-chan Event { |
no test coverage detected