@@ -54,9 +54,9 @@ var waitingJokes = []string{
5454
5555// ConvertOptions contains configuration for PRD conversion.
5656type ConvertOptions struct {
57- PRDDir string // Directory containing prd.md
58- Merge bool // Auto-merge progress on conversion conflicts
59- Force bool // Auto-overwrite on conversion conflicts
57+ PRDDir string // Directory containing prd.md
58+ Merge bool // Auto-merge progress on conversion conflicts
59+ Force bool // Auto-overwrite on conversion conflicts
6060 // RunConversion runs the agent to convert prd.md to JSON. Required.
6161 RunConversion func (absPRDDir string ) (string , error )
6262 // RunFixJSON runs the agent to fix invalid JSON. Required.
@@ -117,7 +117,7 @@ func Convert(opts ConvertOptions) error {
117117 }
118118
119119 // Clean up output (strip markdown fences if any)
120- cleanedJSON := cleanJSONOutput (rawJSON )
120+ cleanedJSON := stripMarkdownFences (rawJSON )
121121
122122 // Parse and validate
123123 newPRD , err := parseAndValidatePRD (cleanedJSON )
@@ -130,7 +130,7 @@ func Convert(opts ConvertOptions) error {
130130 return fmt .Errorf ("conversion retry failed: %w" , retryErr )
131131 }
132132
133- cleanedJSON = cleanJSONOutput (fixedJSON )
133+ cleanedJSON = stripMarkdownFences (fixedJSON )
134134 newPRD , err = parseAndValidatePRD (cleanedJSON )
135135 if err != nil {
136136 return fmt .Errorf ("conversion produced invalid JSON after retry:\n ---\n %s\n ---\n %w" , cleanedJSON , err )
@@ -555,9 +555,9 @@ func NeedsConversion(prdDir string) (bool, error) {
555555 return mdInfo .ModTime ().After (jsonInfo .ModTime ()), nil
556556}
557557
558- // cleanJSONOutput removes markdown code blocks, conversational preamble, and trims
559- // whitespace from Claude's output to extract the JSON object .
560- func cleanJSONOutput (output string ) string {
558+ // stripMarkdownFences removes markdown code blocks and extracts the JSON object.
559+ // This handles output from providers like Claude that may wrap JSON in markdown fences .
560+ func stripMarkdownFences (output string ) string {
561561 output = strings .TrimSpace (output )
562562
563563 // Remove markdown code blocks if present
@@ -573,7 +573,7 @@ func cleanJSONOutput(output string) string {
573573
574574 output = strings .TrimSpace (output )
575575
576- // If output doesn't start with '{', Claude may have added preamble text.
576+ // If output doesn't start with '{', the provider may have added preamble text.
577577 // Extract the JSON object by finding the first '{' and matching closing '}'.
578578 if len (output ) > 0 && output [0 ] != '{' {
579579 start := strings .Index (output , "{" )
0 commit comments