Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 68 additions & 69 deletions internal/app/gpt/gpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,85 +17,84 @@ import (
)

const (
commitSystemPromt = `You are an expert at writing Conventional Commit messages following the v1.0.0 specification.
Analyze the provided git diff and generate a properly formatted commit message.
commitSystemPrompt = `Generate a Conventional Commit message.

STEP 1 - ANALYZE THE DIFF:
Look at the actual content being added/removed/changed. Ask yourself:
- What new text, logic, or functionality was added?
- What was removed or replaced?
- Ignore simple renames/typos if there are bigger changes.

STEP 2 - IDENTIFY THE MAIN CHANGE:
Priority: functional > structural > content > cosmetic
A 50-line prompt rewrite is MORE important than a variable rename in the same diff.

STEP 3 - WRITE THE MESSAGE:
- type: feat|fix|refactor|docs|style|perf|test|build|ci|chore
- scope: ONE word (gpt, auth, cli)
- description: max 50 chars, imperative, no period
- body: bullet list of specific changes, or empty

BANNED in body:
- "for consistency/clarity/correctness"
- "for better/improved X"
- Describing renames when content also changed
- Any justification of why change is "good"

GOOD: "- Add priority rules\n- Add banned phrases list"
BAD: "Renamed variable for consistency"

Return JSON only:
{"type": "...", "scope": "...", "description": "...", "body": "..."}`

changelogSystemPrompt = `Generate a CHANGELOG in Markdown from the provided commits.

RULES:
1. Type: Choose the most appropriate type based on the change:
- feat: new feature or capability
- fix: bug fix or correction
- docs: documentation only changes
- style: code style/formatting (no functional changes)
- refactor: code restructuring (no functional changes)
- perf: performance improvements
- test: adding or updating tests
- build: build system or dependencies
- ci: CI/CD configuration changes
- chore: other changes (tooling, configs)
- revert: reverting a previous commit

2. Scope: A one word noun describing the codebase section or package (e.g., parser, api, auth)

3. Description:
- Start with uppercase letter
- Use imperative mood ("Add" not "Added" or "Adds")
- No period at the end
- Be concise but clear

4. Body: Provide additional context if the change is non-trivial.
- Use to explain "what" and "why", not "how"
- Wrap at 72 characters

EXAMPLES:
- feat(auth): Add OAuth2 login support
- docs(readme): Update installation instructions
- refactor(parser): Extract validation logic into separate function

Return ONLY valid JSON in this format:
{
"type": "feat, fix, build, chore, ci, docs, style, refactor, perf, test, revert",
"scope": "scope of the change (use one word)",
"description": "a brief description of what was changed in imperative mood",
"body": "optional detailed explanation"
}`

changelogSystemPrompt = `You are an experienced Software Engineer tasked with generating a concise and clear CHANGELOG for a set of commits in Markdown format.
Follow these instructions:
– Keep the content concise, using short bullet points for each entry
– Do not elaborate unnecessarily. Focus on the core details
– Ensure proper formatting for easy readability
– Do not include empty sections

Follow the format below:
- One short bullet per change
- Focus on functional changes (features, fixes), not internal refactors
- Only include sections that have actual entries
- No filler phrases ("for clarity", "for consistency", "improved X")

EMPTY SECTIONS:
BAD (never do this):
### Fixes
- None
### Breaking Changes
- N/A

GOOD (just omit empty sections):
### Features
- Add user authentication

PRIORITY (what to include):
1. Features and fixes - always include
2. Breaking changes - always include
3. Performance - include if significant
4. Build/CI - include if affects users
5. Refactor/style/chore/tests - omit unless notable

FORMAT (in this order, omit empty sections):

# CHANGELOG

## [X.Y.Z]

### Breaking Changes
- What breaks and migration steps

### Features
- **feat:** ...
- Short description (no "feat:" prefix, section name is enough)

### Fixes
- **fix:** ...
- Short description (no "fix:" prefix)

### Performance
- **perf:** ...
### Refactor
- **refactor:** ...
- Short description

### Documentation
- **docs:** ...
### Style
- **style:** ...
### Tests
- **test:** ...
### Build
- **build:** ...
### CI
- **ci:** ...
### Chore
- **chore:** ...
### Reverts
- **revert:** ...
### Breaking Changes
- **BREAKING CHANGES:** ...`
- Short description

Do NOT include: Tests, Chore, Style, CI, Build (unless affects end users)`
)

type commitType string
Expand Down Expand Up @@ -173,7 +172,7 @@ func (g *client) FetchCommitMessage(ctx context.Context, diff string) (string, e
messages := []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleSystem,
Content: commitSystemPromt,
Content: commitSystemPrompt,
},
{
Role: openai.ChatMessageRoleUser,
Expand Down