Files
java-ai-agents/release-notes-ai/README.md
T

2.4 KiB

release-notes-ai

Companion code for the ankurm.com post AI Release Notes and PR Descriptions in Java: JGit, Spring AI and Gitea.

It reads a real Git repository with JGit, groups commits by Conventional Commit type, works out the next version, renders release notes in code, asks a Spring AI ChatModel only for a short opening paragraph (and a PR summary), rejects any answer that cites a commit or PR number it was not given, and publishes to Gitea so that running twice edits instead of failing.

Every transcript in output/ is written by the test that asserts the same facts: mvn test regenerates all of them. The tests build a real repository with JGit (fixed dates, so the hashes are stable). The language model is StubChatModel, a deterministic stand-in, and Gitea is FakeGitea, a small local HTTP server in the test sources. Neither is the real thing and the post says so.

Class Job
ConventionalCommit parse type(scope)!: description, BREAKING CHANGE: footers and (#123) suffixes
GitHistory JGit: commits between two refs, previous tag, merge base, per-commit and per-branch diffs
ReleaseModel, SemVer group by type and compute the version bump
ReleaseNotes Markdown rendering, links and the no-model fallback sentence
Highlights the one model call for release notes, plus the answer guard
DiffBudget, PrDescription cap what the model sees of a branch diff and build the PR body
GiteaClient create-or-update a release and a pull request
StubChatModel stand-in model with modes that misbehave on purpose

Run

mvn -pl release-notes-ai test        # JDK 25
Output Shows
01-commit-parsing.txt what the parser does with eleven messages, good and bad
02-history-range.txt v1.0.0..v1.1.0 read with JGit, the root-commit and annotated-tag traps, previous tag
03-grouped-release-notes.txt grouped, ordered notes and the implied version
04-model-guard.txt the exact prompt, and three bad answers rejected
05-pull-request-description.txt merge-base diff, diff budget, the PR body
06-gitea-publish.txt create then update for a release and a PR, a 401, and the requests seen
07-command-line.txt ReleaseNotesApp on the fixture repository

To use a real model, put any Spring AI ChatModel (Anthropic, OpenAI, Ollama) where new StubChatModel() is constructed. No other code changes.