package infra import ( "bytes" "fmt" "os" "gopkg.in/yaml.v3" ) // WriteIssueMd serializa el frontmatter del Issue a YAML y lo escribe en path junto al body. // El archivo resultante tiene formato: "---\n---\n". // El body se preserva exactamente tal como fue recibido (sin normalizar trailing newlines). // Los campos de runtime (FilePath, MtimeNs, Completed) se omiten del YAML via yaml:"-". func WriteIssueMd(path string, iss Issue, body []byte) error { var buf bytes.Buffer yamlBytes, err := yaml.Marshal(iss) if err != nil { return fmt.Errorf("write_issue_md: marshal %s: %w", path, err) } buf.WriteString("---\n") buf.Write(yamlBytes) buf.WriteString("---\n") buf.Write(body) if err := os.WriteFile(path, buf.Bytes(), 0644); err != nil { return fmt.Errorf("write_issue_md: write %s: %w", path, err) } return nil }