Jelajahi Sumber

Merge pull request #927 from thesimplekid/goose_in_ci

Goose changelog recipes
thesimplekid 2 bulan lalu
induk
melakukan
9e4b768657
4 mengubah file dengan 93 tambahan dan 5 penghapusan
  1. 1 0
      CHANGELOG.md
  2. 11 5
      justfile
  3. 76 0
      misc/recipes/changelog-from-commits.yaml
  4. 5 0
      misc/recipes/changelog-update.yaml

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@
 ## [Unreleased]
 
 ### Added
+- dev: Goose recipes for changelog and commit message generation with Just commands ([thesimplekid]).
 - cashu: `KeySetInfos` type alias and `KeySetInfosMethods` trait for filtering keysets ([thesimplekid]).
 - cdk: Mint lifecycle management with `start()` and `stop()` methods for graceful background service control ([thesimplekid]).
 - cdk: Background task management for invoice payment monitoring with proper shutdown handling ([thesimplekid]).

+ 11 - 5
justfile

@@ -131,16 +131,22 @@ typos-fix:
 
 # Goose AI Recipe Commands
 
-# Create git message from staged changes using Goose AI
-goose-changelog-update:
-  #!/usr/bin/env bash
-  goose run --recipe ./misc/recipes/changelog-update.yaml --interactive
-  
 # Update changelog from staged changes using Goose AI  
 goose-git-msg:
   #!/usr/bin/env bash
   goose run --recipe ./misc/recipes/git-commit-message.yaml --interactive
 
+# Create git message from staged changes using Goose AI
+goose-changelog-staged:
+  #!/usr/bin/env bash
+  goose run --recipe ./misc/recipes/changelog-update.yaml --interactive
+
+# Update changelog from recent commits using Goose AI
+# Usage: just goose-changelog-commits [number_of_commits]
+goose-changelog-commits *COMMITS="5":
+  #!/usr/bin/env bash
+  COMMITS={{COMMITS}} goose run --recipe ./misc/recipes/changelog-from-commits.yaml --interactive
+
 itest db:
   #!/usr/bin/env bash
   ./misc/itests.sh "{{db}}"

+ 76 - 0
misc/recipes/changelog-from-commits.yaml

@@ -0,0 +1,76 @@
+version: 1.0.0
+title: Update Changelog from last commits
+description: A custom recipe to update changelog from the last X commits
+instructions: Analyze recent Git commits and automatically update project changelogs following Keep a Changelog format. Read commit history using git log, understand the nature of code changes (API refactoring, new features, bug fixes, etc.), and add appropriately categorized entries to the Unreleased section. Use the git author's username for attribution and follow established changelog patterns including proper formatting with contributor links. Requires git command line tools and file editing capabilities.
+prompt: |
+  You are tasked with updating the CHANGELOG.md file based on recent Git commits. Follow these instructions:
+
+  ## Analysis Process:
+  1. **Get commit count**: Check if a COMMITS environment variable was provided (default to 5 if not specified)
+  2. **Read recent commits**: Use `git log -n X` to analyze the last X commits (where X is the number specified by user or default)
+  3. **Get git author**: Use `git config --get user.name` to get the author name for attribution
+  4. **Analyze change types**: Categorize changes into:
+     - **Added**: New features, new functions, new files, new functionality
+     - **Changed**: Modifications to existing functionality, refactoring, API changes, dependency updates
+     - **Fixed**: Bug fixes, error handling improvements, corrections
+     - **Removed**: Deleted files, deprecated functions, removed dependencies
+
+  ## CHANGELOG.md Update Requirements:
+  1. **Preserve existing format**: Keep the exact formatting style of the existing CHANGELOG.md
+  2. **Update Unreleased section**: Add new entries to the "## [Unreleased]" section only
+  3. **Use proper categories**: Add entries under the appropriate subsections (Added, Changed, Fixed, Removed)
+  4. **Follow format pattern**: Each entry should follow this exact format:
+     ```
+     - component: Description of change ([author]).
+     ```
+  5. **Author attribution**: Use the git author name in square brackets at the end of each entry
+  6. **Component identification**: Identify the relevant component (e.g., "cdk", "cashu", "cdk-cli", etc.) from file paths
+  7. **Maintain formatting**: 
+     - Use proper bullet points with hyphens
+     - Maintain consistent spacing
+     - Keep entries concise but descriptive
+     - End each entry with period before author attribution
+
+  ## Example Entry Format:
+  ```markdown
+  ### Added
+  - cdk: New keyset refresh functionality with improved error handling ([thesimplekid]).
+
+  ### Changed  
+  - cdk: Refactored wallet keyset management for better performance ([thesimplekid]).
+
+  ### Fixed
+  - cdk-cli: Fixed token parsing error for malformed inputs ([thesimplekid]).
+  ```
+
+  ## Important Guidelines:
+  - **DO NOT** modify any existing changelog entries
+  - **DO NOT** change the structure or format of the changelog
+  - **ONLY** add new entries to the Unreleased section
+  - **DO NOT** add duplicate entries
+  - **BE SPECIFIC** about what changed, not just which files
+  - **FOCUS** on user-facing changes and important internal improvements
+  - **IGNORE** trivial changes like whitespace, comments, or formatting unless they're significant
+
+  ## Steps to Execute:
+  1. Check for COMMITS environment variable or ask user for the number of recent commits to analyze (default to 5)
+  2. Read current CHANGELOG.md file to understand format
+  3. Get git author name  
+  4. Analyze recent commits with `git log -n X --pretty=format:"%h %s"`
+  5. For each commit, examine detailed changes with `git show COMMIT_HASH`
+  6. Categorize and write appropriate changelog entries
+  7. Update the CHANGELOG.md file preserving all existing content
+extensions:
+- type: builtin
+  name: developer
+  display_name: Developer
+  timeout: 300
+  bundled: true
+activities:
+- Update changelog from recent commits
+- Analyze API refactoring commits
+- Add new feature entries
+- Categorize bug fix changes
+- Format contributor attributions
+author:
+  contact: thesimplekid

+ 5 - 0
misc/recipes/changelog-update.yaml

@@ -57,6 +57,11 @@ prompt: |
   3. Analyze staged changes with `git diff --staged`
   4. Categorize and write appropriate changelog entries
   5. Update the CHANGELOG.md file preserving all existing content
+
+  ## Alternative Recipe:
+  If you want to generate changelog entries from recent commits instead of staged changes, see the 
+  `changelog-from-commits.yaml` recipe which analyzes the last X commits instead of staged changes.
+
 extensions:
 - type: builtin
   name: developer