@@ -17,6 +17,7 @@ func main() {
1717 version := flag .String ("version" , "" , "Version to generate notes for (e.g., v0.7.3)" )
1818 sinceTag := flag .String ("since" , "" , "Generate notes since this tag (auto-detects if empty)" )
1919 output := flag .String ("output" , "" , "Output file (prints to stdout if empty)" )
20+ aiPrompt := flag .Bool ("ai-prompt" , false , "Generate prompt for Claude Code to enhance release notes" )
2021 flag .Parse ()
2122
2223 // Get the tag to compare from
@@ -58,18 +59,31 @@ func main() {
5859 fmt .Fprintf (os .Stderr , " Extracted context: ~%d tokens from %d files\n " ,
5960 result .TokenCount , len (result .ProjectOutput .Files ))
6061
61- // Generate release notes
62- fmt .Fprintln (os .Stderr , "\n 📝 Generating release notes...\n " )
63- releaseNotes := generateReleaseNotes (* version , fromTag , commits , result )
62+ // Generate release notes or AI prompt
63+ if * aiPrompt {
64+ fmt .Fprintln (os .Stderr , "\n 📝 Generating Claude Code prompt...\n " )
65+ prompt := generateClaudeCodePrompt (* version , fromTag , commits , result )
6466
65- // Output
66- if * output != "" {
67- if err := os .WriteFile (* output , []byte (releaseNotes ), 0644 ); err != nil {
68- log .Fatalf ("Failed to write output: %v" , err )
67+ if * output != "" {
68+ if err := os .WriteFile (* output , []byte (prompt ), 0644 ); err != nil {
69+ log .Fatalf ("Failed to write output: %v" , err )
70+ }
71+ fmt .Fprintf (os .Stderr , "✅ Prompt written to %s\n " , * output )
72+ } else {
73+ fmt .Println (prompt )
6974 }
70- fmt .Fprintf (os .Stderr , "✅ Release notes written to %s\n " , * output )
7175 } else {
72- fmt .Println (releaseNotes )
76+ fmt .Fprintln (os .Stderr , "\n 📝 Generating release notes...\n " )
77+ releaseNotes := generateReleaseNotes (* version , fromTag , commits , result )
78+
79+ if * output != "" {
80+ if err := os .WriteFile (* output , []byte (releaseNotes ), 0644 ); err != nil {
81+ log .Fatalf ("Failed to write output: %v" , err )
82+ }
83+ fmt .Fprintf (os .Stderr , "✅ Release notes written to %s\n " , * output )
84+ } else {
85+ fmt .Println (releaseNotes )
86+ }
7387 }
7488}
7589
@@ -246,3 +260,76 @@ func generateReleaseNotes(version, fromTag string, commits []string, result *pro
246260
247261 return notes .String ()
248262}
263+
264+ // generateClaudeCodePrompt generates a prompt for Claude Code to enhance release notes
265+ func generateClaudeCodePrompt (version , fromTag string , commits []string , result * promptext.Result ) string {
266+ var prompt strings.Builder
267+
268+ // Determine version
269+ if version == "" {
270+ version = "0.7.4"
271+ }
272+
273+ prompt .WriteString ("# Release Notes Enhancement Request\n \n " )
274+ prompt .WriteString ("Please generate comprehensive release notes for promptext version " + version + "\n \n " )
275+
276+ prompt .WriteString ("## Context\n \n " )
277+ prompt .WriteString (fmt .Sprintf ("- **Version**: %s\n " , version ))
278+ prompt .WriteString (fmt .Sprintf ("- **Changes since**: %s\n " , fromTag ))
279+ prompt .WriteString (fmt .Sprintf ("- **Commits analyzed**: %d\n " , len (commits )))
280+ prompt .WriteString (fmt .Sprintf ("- **Files changed**: %d\n " , len (result .ProjectOutput .Files )))
281+ prompt .WriteString (fmt .Sprintf ("- **Context extracted**: ~%d tokens\n \n " , result .TokenCount ))
282+
283+ prompt .WriteString ("## Commit History\n \n " )
284+ prompt .WriteString ("```\n " )
285+ for _ , commit := range commits {
286+ prompt .WriteString (commit + "\n " )
287+ }
288+ prompt .WriteString ("```\n \n " )
289+
290+ prompt .WriteString ("## Changed Files Summary\n \n " )
291+ for _ , file := range result .ProjectOutput .Files {
292+ prompt .WriteString (fmt .Sprintf ("- `%s` (~%d tokens)\n " , file .Path , file .Tokens ))
293+ }
294+ prompt .WriteString ("\n " )
295+
296+ prompt .WriteString ("## Code Context (via promptext)\n \n " )
297+ prompt .WriteString ("```\n " )
298+ prompt .WriteString (result .FormattedOutput )
299+ prompt .WriteString ("\n ```\n \n " )
300+
301+ prompt .WriteString ("## Task\n \n " )
302+ prompt .WriteString ("Generate release notes in Keep a Changelog format with these sections:\n \n " )
303+ prompt .WriteString ("### Added\n " )
304+ prompt .WriteString ("- New features (be specific and detailed)\n " )
305+ prompt .WriteString ("- Focus on user-facing value\n \n " )
306+ prompt .WriteString ("### Changed\n " )
307+ prompt .WriteString ("- Improvements and modifications\n \n " )
308+ prompt .WriteString ("### Fixed\n " )
309+ prompt .WriteString ("- Bug fixes\n \n " )
310+ prompt .WriteString ("### Documentation\n " )
311+ prompt .WriteString ("- Doc updates\n \n " )
312+
313+ prompt .WriteString ("## Requirements\n \n " )
314+ prompt .WriteString ("1. Use the commit history and code context to write detailed, clear descriptions\n " )
315+ prompt .WriteString ("2. Group related changes together logically\n " )
316+ prompt .WriteString ("3. Focus on user impact, not implementation details\n " )
317+ prompt .WriteString ("4. Be specific about what changed and why it matters\n " )
318+ prompt .WriteString ("5. Follow Keep a Changelog format\n " )
319+ prompt .WriteString ("6. Include markdown formatting for code, paths, etc.\n \n " )
320+
321+ prompt .WriteString ("## Example Format\n \n " )
322+ prompt .WriteString ("```markdown\n " )
323+ prompt .WriteString ("## [" + version + "] - " + time .Now ().Format ("2006-01-02" ) + "\n \n " )
324+ prompt .WriteString ("### Added\n " )
325+ prompt .WriteString ("- **Release Notes Generator**: Automated tool using promptext library to analyze git changes\n " )
326+ prompt .WriteString (" - Extracts code context with token-aware analysis\n " )
327+ prompt .WriteString (" - Categorizes commits by type (feat, fix, docs)\n " )
328+ prompt .WriteString (" - Generates changelog-compatible markdown\n \n " )
329+ prompt .WriteString ("...\n " )
330+ prompt .WriteString ("```\n \n " )
331+
332+ prompt .WriteString ("Please generate the complete, polished release notes now.\n " )
333+
334+ return prompt .String ()
335+ }
0 commit comments