Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat(release): migrate to towncrier news fragments (#3773)

LearningCircuitb632ca8ec4cd
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8c8fff403c..f75b4f4715 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -390,7 +390,9 @@ jobs:
#
# Body layout (each section is omitted if its source is empty):
# 1. AI-generated TL;DR (from OpenRouter, model = vars.AI_MODEL)
- # 2. Hand-written notes from docs/release_notes/<version>.md
+ # 2. Hand-written narrative — docs/release_notes/<version>.md,
+ # rendered from changelog.d/ fragments by
+ # `pdm run towncrier build` at release prep time.
# 3. Horizontal rule
# 4. Auto-generated, label-categorized PR list (already starts
# with "## What's Changed", emitted by GitHub's generate-notes
@@ -401,13 +403,12 @@ jobs:
# must never fail because of an LLM hiccup.
set -euo pipefail
- # Defense-in-depth: reject anything that could escape docs/release_notes/
- # via path traversal. RELEASE_VERSION is the bare semver (no `v`
- # prefix) — the build job's "Determine version" step strips
- # `refs/tags/v` for tag pushes and reads __version__.py (bare
- # "1.6.7") otherwise. A leading `v` here would mean an upstream
- # contract change and should fail loudly rather than silently miss
- # the notes file (`docs/release_notes/v1.7.0.md` does not exist).
+ # Defense-in-depth: RELEASE_VERSION is interpolated into a regex
+ # below, so reject anything that isn't a bare semver string. The
+ # build job's "Determine version" step strips `refs/tags/v` for
+ # tag pushes and reads __version__.py (bare "1.6.7") otherwise,
+ # so a leading `v` here would mean an upstream contract change
+ # and should fail loudly.
if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][a-zA-Z0-9.+_-]+)?$ ]]; then
echo "ERROR: RELEASE_VERSION '$RELEASE_VERSION' is not a valid bare semver string" >&2
exit 1
@@ -429,9 +430,15 @@ jobs:
exit 1
fi
+ # The hand-written narrative is the per-version file produced by
+ # `pdm run towncrier build` from changelog.d/ fragments. Empty if
+ # the maintainer forgot to render before bumping __version__.py —
+ # release proceeds with auto-notes only.
HAND_NOTES=""
if [[ -f "$RELEASE_NOTES_FILE" ]]; then
HAND_NOTES=$(cat "$RELEASE_NOTES_FILE")
+ else
+ echo "WARNING: $RELEASE_NOTES_FILE not found — release proceeds with auto-notes only"
fi
# ---- AI TL;DR (best-effort) -----------------------------------------
diff --git a/.gitignore b/.gitignore
index 92883f8d28..4fc240e18d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -307,6 +307,8 @@ tests/ui_tests/mobile/*-screenshots/
!docs/**/*.md
!examples/**/*.md
!cookiecutter-docker/**/*.md
+# towncrier news fragments
+!changelog.d/**/*.md
# Block MD files in tests directories by default
tests/**/*.md
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c8003d8113..ba55cedf13 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -302,7 +302,7 @@ repos:
pass_filenames: false
always_run: true
verbose: true
- description: "Remind contributors to update docs/release_notes/ for substantial changes"
+ description: "Remind contributors to add a changelog.d/<id>.<category>.md fragment for substantial changes (rendered by towncrier at release prep)"
- id: require-tests
name: Require Tests for Substantial Changes
entry: .pre-commit-hooks/require-tests.py
diff --git a/.pre-commit-hooks/recommend-release-notes.py b/.pre-commit-hooks/recommend-release-notes.py
index de886c321a..1826238e43 100755
--- a/.pre-commit-hooks/recommend-release-notes.py
+++ b/.pre-commit-hooks/recommend-release-notes.py
@@ -1,15 +1,21 @@
#!/usr/bin/env python3
-"""Remind contributors about release notes.
+"""Remind contributors about news fragments.
Always exits 0 (non-blocking). Two messages:
-- When any file under docs/release_notes/ is staged: confirm that the
- file ends up in the GitHub release body and give brief format tips.
-- When source changes are substantial but no release-notes file is
- staged: nudge the contributor to add one.
+- When any file under changelog.d/ is staged: confirm that the fragment
+ will be rolled into the next release's notes by towncrier and validate
+ the filename matches the expected pattern.
+- When source changes are substantial but no fragment is staged: nudge
+ the contributor to add one.
+
+Replaces the old shared docs/release_notes/<version>.md model — see
+changelog.d/README.md for the rationale and conventions.
"""
+import re
import subprocess
import sys
+import tomllib
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
@@ -19,120 +25,155 @@ from _commit_analysis import analyze_commit
# Minimum added source lines before the nudge fires
MIN_SOURCE_ADDED = 20
-# Phrases that mark a file as in-progress staging text rather than
-# ready-to-publish release prose. These would otherwise publish verbatim
-# into the GitHub release body — the workflow prepends the file as-is.
-STAGING_MARKERS = (
- "(pending)",
- "Staging notes",
- "Fold into the next tagged version",
-)
+REPO_ROOT = Path(__file__).resolve().parent.parent
+PYPROJECT = REPO_ROOT / "pyproject.toml"
+
+
+def _load_categories():
+ """Read [[tool.towncrier.type]].directory entries from pyproject.toml so
+ the hook stays in sync with the canonical category list. Falls back to
+ a sensible default if the file or section is missing — the hook is
+ non-blocking so a degraded mode is preferable to a hard failure."""
+ try:
+ with PYPROJECT.open("rb") as fh:
+ cfg = tomllib.load(fh)
+ except (OSError, tomllib.TOMLDecodeError):
+ return ("breaking", "security", "feature", "bugfix", "removal", "misc")
+ types = cfg.get("tool", {}).get("towncrier", {}).get("type", [])
+ cats = tuple(t["directory"] for t in types if "directory" in t)
+ return cats or (
+ "breaking",
+ "security",
+ "feature",
+ "bugfix",
+ "removal",
+ "misc",
+ )
-def _release_notes_staged():
- """Return the list of staged files under docs/release_notes/."""
- result = subprocess.run(
- ["git", "diff", "--cached", "--name-only", "--", "docs/release_notes/"],
- capture_output=True,
- text=True,
- )
- return [line for line in result.stdout.strip().splitlines() if line]
+CATEGORIES = _load_categories()
+
+# changelog.d/<id>.<category>.md or changelog.d/+<slug>.<category>.md
+# - <id>: integer PR/issue number
+# - +<slug>: orphan fragment with no PR/issue, slug is [A-Za-z0-9_-]+
+FRAGMENT_RE = re.compile(
+ r"^(?:\d+|\+[A-Za-z0-9_-]+)\.(?P<category>[a-z]+)\.md$"
+)
+# Color helpers: only emit ANSI when stdout is a TTY. CI logs and Windows
+# terminals without VT processing render the raw escape sequences as
+# visible garbage.
+_USE_COLOR = sys.stdout.isatty()
+_CYAN = "\033[36m" if _USE_COLOR else ""
+_YELLOW = "\033[33m" if _USE_COLOR else ""
+_RESET = "\033[0m" if _USE_COLOR else ""
-def _scan_staging_markers(path):
- """Return a list of (line_num, marker, snippet) for each staging marker
- found in the staged version of ``path``. Empty list if the file is
- being deleted or has no markers."""
+
+def _fragments_staged():
+ """Return the list of staged files under changelog.d/, excluding
+ README.md and other non-fragment files."""
result = subprocess.run(
- ["git", "show", f":{path}"],
+ ["git", "diff", "--cached", "--name-only", "--", "changelog.d/"],
capture_output=True,
text=True,
)
- if result.returncode != 0:
- return []
- hits = []
- for i, line in enumerate(result.stdout.splitlines(), start=1):
- lowered = line.lower()
- for marker in STAGING_MARKERS:
- if marker.lower() in lowered:
- snippet = line.strip()
- if len(snippet) > 80:
- snippet = snippet[:77] + "..."
- hits.append((i, marker, snippet))
- break
- return hits
+ files = [line for line in result.stdout.strip().splitlines() if line]
+ return [
+ f for f in files if f.endswith(".md") and Path(f).name != "README.md"
+ ]
+
+
+def _classify_fragment(path):
+ """Return ("ok", category) for a valid fragment, ("bad-category", cat)
+ for a fragment whose category isn't in CATEGORIES, or ("bad-name", None)
+ for a filename that doesn't match the expected pattern at all."""
+ name = Path(path).name
+ m = FRAGMENT_RE.match(name)
+ if not m:
+ return "bad-name", None
+ category = m.group("category")
+ if category not in CATEGORIES:
+ return "bad-category", category
+ return "ok", category
def _print_staged_notice(staged):
- """Inform the committer that a release-notes file was staged."""
+ """Inform the committer that a news fragment was staged."""
print()
- print(" \033[36mRelease Notes Staged\033[0m")
+ print(f" {_CYAN}News Fragment Staged{_RESET}")
print(" " + "-" * 40)
for f in staged:
print(f" - {f}")
print()
- print(" Files matching docs/release_notes/<version>.md are prepended")
- print(" to the GitHub release body when that tag is cut")
- print(" (.github/workflows/release.yml).")
-
- # Warn (non-blocking) if any staged file still contains staging markers.
- # These would publish verbatim into the release body.
- findings = {f: _scan_staging_markers(f) for f in staged}
- findings = {f: hits for f, hits in findings.items() if hits}
- if findings:
+ print(" Files under changelog.d/ are rendered into")
+ print(" docs/release_notes/<version>.md at release prep time by")
+ print(" `pdm run towncrier build --version <X.Y.Z> --yes`, then")
+ print(" surfaced in the GitHub release body by")
+ print(" .github/workflows/release.yml.")
+
+ # Validate filenames — non-blocking, but a typo'd category silently
+ # falls through towncrier's "no fragments matched" branch and the
+ # contributor's note vanishes from the release.
+ issues = []
+ for f in staged:
+ kind, value = _classify_fragment(f)
+ if kind != "ok":
+ issues.append((f, kind, value))
+ if issues:
print()
- print(
- " \033[33m⚠ Staging markers detected — will publish verbatim:\033[0m"
- )
- for f, hits in findings.items():
- print(f" {f}")
- for line_num, marker, snippet in hits:
- print(f" L{line_num} [{marker}]: {snippet}")
+ print(f" {_YELLOW}⚠ Fragment filename problems:{_RESET}")
+ for f, kind, value in issues:
+ if kind == "bad-name":
+ print(
+ f" {f} — does not match `<id>.<category>.md` or "
+ f"`+<slug>.<category>.md`"
+ )
+ else:
+ print(
+ f" {f} — unknown category `{value}`. Use one of: "
+ f"{', '.join(CATEGORIES)}"
+ )
print()
- print(" Strip these before tagging the release.")
+ print(" See changelog.d/README.md for the convention.")
print()
print(" Format tips:")
- print(" - Start with a short summary paragraph. No top-level `#`")
- print(" heading — the release title is rendered separately, so")
- print(" a leading H1 looks oversized.")
- print(" - Use `##` sections: BREAKING, New Features, Bug Fixes,")
- print(" Settings, Operational notes — only the ones that apply.")
- print(" - Mark breaking changes as `## BREAKING — <summary>` with")
- print(" an `### Impact` subsection listing who is affected.")
- print(" - Link PRs as `[#1234](https://github.com/.../pull/1234)`.")
- print(" - Before tagging: strip staging markers like `(pending)`")
- print(" or `Fold into the next tagged version` — they publish")
- print(" verbatim into the release body.")
+ print(" - One sentence is usually enough; longer prose is fine for")
+ print(" breaking changes that need a 'what to do' line.")
+ print(" - Markdown is supported. The PR/issue link is auto-appended")
+ print(" based on the fragment id (no need to add `(#NNNN)`).")
+ print(" - Skip dependency bumps, internal CI tweaks, and refactors")
+ print(" with no user-visible behavior — the auto-PR-list catches")
+ print(" those without a fragment.")
print()
def _print_missing_notice(analysis):
- """Nudge the committer to add release notes for a substantial change."""
+ """Nudge the committer to add a news fragment for a substantial change."""
print()
- print(" \033[36mRelease Notes Reminder\033[0m")
+ print(f" {_CYAN}News Fragment Reminder{_RESET}")
print(" " + "-" * 40)
print(
f" You're adding {analysis.total_source_added} lines across "
f"{len(analysis.source_files)} source file(s)"
)
- print(" but no files under docs/release_notes/ are staged.")
+ print(" but no changelog.d/ fragment is staged.")
print()
print(" Changed source files:")
for f in analysis.source_files:
print(f" - {f.path} (+{f.added})")
print()
- print(" Consider adding an entry to docs/release_notes/ if this")
- print(" change is user-facing or otherwise notable. Files matching")
- print(" the released <version>.md are auto-prepended to the GitHub")
- print(" release body when the tag is cut.")
+ print(" If this change is user-facing, drop a fragment under")
+ print(" changelog.d/ named `<PR-number>.<category>.md` (categories:")
+ print(f" {', '.join(CATEGORIES)}). See changelog.d/README.md.")
print()
def main():
- staged = _release_notes_staged()
+ staged = _fragments_staged()
- # Always inform when release notes are staged — contributors should
- # know the file gets published, not just archived as docs.
+ # Always inform when a fragment is staged — contributors should know
+ # the file gets rendered into the release, and any naming mistakes
+ # need to surface before the fragment silently goes ignored.
if staged:
_print_staged_notice(staged)
return 0
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 04fb08e986..85ebaa79bd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -91,7 +91,8 @@ Pre-commit hooks will automatically:
4. **Write clear commit messages** — Explain what and why, not just what changed
5. **Add tests** — Include tests for new functionality
6. **Update documentation** — Keep docs in sync with code changes
-7. **Ensure CI passes** — All automated checks must pass. Address CI failures promptly
+7. **Add a release-notes fragment** — If your change is user-visible (new feature, bug fix, breaking change, security fix, etc.), drop a one-line markdown file at `changelog.d/<PR-number>.<category>.md` where `<category>` is one of `breaking`, `security`, `feature`, `bugfix`, `removal`, `misc`. The pre-commit hook will nudge you if you forget. See [`changelog.d/README.md`](changelog.d/README.md) for the convention. Skip for dep bumps, CI tweaks, and pure refactors — the auto-generated PR list catches those.
+8. **Ensure CI passes** — All automated checks must pass. Address CI failures promptly
We will review your pull request and either merge it, request changes, or close it with an explanation. Don't worry about things like commit message formatting — we squash-merge and can adjust the final message.
diff --git a/changelog.d/3773.feature.md b/changelog.d/3773.feature.md
new file mode 100644
index 0000000000..864e01eb19
--- /dev/null
+++ b/changelog.d/3773.feature.md
@@ -0,0 +1 @@
+**Release notes now use [towncrier](https://towncrier.readthedocs.io) news fragments.** Each PR drops one tiny `changelog.d/<id>.<category>.md` file (categories: `breaking`, `security`, `feature`, `bugfix`, `removal`, `misc`). At release prep, the maintainer runs `pdm run towncrier build --version <X.Y.Z> --yes`, which renders the fragments into `docs/release_notes/<X.Y.Z>.md` and removes them. Replaces the previous shared-file workflow, which scaled poorly at LDR's PR throughput. See `changelog.d/README.md` for the convention.
diff --git a/changelog.d/README.md b/changelog.d/README.md
new file mode 100644
index 0000000000..b96643a6fb
--- /dev/null
+++ b/changelog.d/README.md
@@ -0,0 +1,97 @@
+# Release-notes news fragments
+
+Each PR with user-visible behavior change drops one tiny markdown file in
+this directory. At release prep time the maintainer runs
+`pdm run towncrier build --version <X.Y.Z> --yes`, which renders the
+fragments into `docs/release_notes/<X.Y.Z>.md` and removes them. The
+release workflow surfaces that file in the published GitHub release body.
+
+This per-PR fragment model replaces the old approach where every
+contributor edited a shared `docs/release_notes/<version>.md` — that
+broke down at LDR's PR throughput (12+ PRs/day, 25–50 PRs per release).
+
+## Naming
+
+```
+changelog.d/<id>.<category>.md
+changelog.d/+<slug>.<category>.md # orphan (no PR/issue number)
+```
+
+- `<id>` — the PR or issue number (e.g., `3768`). The rendered changelog
+ links to it via the `issue_format` template in `pyproject.toml`.
+- `+<slug>` — for fragments where no PR/issue number applies. The `+`
+ prefix tells towncrier this is an orphan fragment.
+- `<category>` — one of the `[[tool.towncrier.type]]` directories
+ declared in `pyproject.toml` (currently: `breaking`, `security`,
+ `feature`, `bugfix`, `removal`, `misc`).
+
+## What goes in the file
+
+A short user-facing description of the change. One sentence is usually
+enough; longer prose is fine for breaking changes that need a "what to
+do" line. Markdown is supported.
+
+Examples:
+
+```markdown
+# changelog.d/3768.feature.md
+Release notes are now prepended to the GitHub release body, with an
+AI-generated TL;DR at the top.
+```
+
+```markdown
+# changelog.d/3670.breaking.md
+**`llm.model` no longer auto-fills `gemma3:12b`.** Set the model
+explicitly in Settings → LLM, or research will fail loudly with a
+clear `ValueError`.
+```
+
+## What does NOT go here
+
+- Dependency bumps (the auto-generated PR list catches these).
+- CI/workflow tweaks invisible to users.
+- Internal refactors with no behavior change.
+- Doc-only changes unless the new doc is itself the user-facing point.
+
+If in doubt, ask: *would a user want to read about this on the GitHub
+release page?* If no, skip the fragment.
+
+## Categories
+
+| directory | rendered as | use for |
+|-------------|----------------------|---------|
+| `breaking` | 💥 Breaking Changes | API/CLI/config that is no longer compatible with prior releases |
+| `security` | 🔒 Security | CVE fixes, hardening users should know about |
+| `feature` | ✨ New Features | New user-facing capability |
+| `bugfix` | 🐛 Bug Fixes | User-visible bug fix |
+| `removal` | 🗑️ Removed | Removed setting, endpoint, or feature |
+| `misc` | 📝 Other Changes | Anything else worth highlighting |
+
+## Release flow (for maintainers)
+
+```bash
+# As part of release prep:
+pdm run towncrier build --version 1.6.9 --yes
+# bump __version__.py to 1.6.9
+git add src/local_deep_research/__version__.py docs/release_notes/1.6.9.md
+git commit -m "chore(release): bump to 1.6.9 + render news fragments"
+git push
+```
+
+Towncrier (configured under `[tool.towncrier]` in `pyproject.toml` with
+`single_file = false` and `filename = "docs/release_notes/{version}.md"`):
+
+1. Reads fragments from `changelog.d/`.
+2. Renders them into `docs/release_notes/1.6.9.md`.
+3. `git rm`s the consumed fragments (deletion staged for commit).
+4. Stages the new release-notes file via `git add`.
+
+To preview without touching anything (e.g., while iterating on a
+fragment locally):
+
+```bash
+pdm run towncrier build --draft --version 1.6.9
+```
+
+The release workflow reads `docs/release_notes/<version>.md` for the
+human-narrative input to the published release body.
diff --git a/docs/RELEASE_GUIDE.md b/docs/RELEASE_GUIDE.md
index eab443542d..b6732d3813 100644
--- a/docs/RELEASE_GUIDE.md
+++ b/docs/RELEASE_GUIDE.md
@@ -2,15 +2,37 @@
## 🚀 Automated Release Process
-Releases are now **fully automated** when PRs are merged to the `main` branch.
+Releases are **fully automated** end-to-end whenever a PR that bumps
+`src/local_deep_research/__version__.py` is merged to `main`. No
+separate tag push, manual workflow trigger, or release-page click is
+required — the workflow detects the new version, runs all gates, cuts
+the GitHub release, and (after one approval click) publishes to PyPI
+and Docker Hub.
+
+PRs that don't touch `__version__.py` merge normally but skip the
+release pipeline (the version-check job sees the tag already exists
+and short-circuits everything downstream).
## 📋 How Releases Work
### 1. **Automatic Release Creation**
-- **Trigger**: Any merge to `main` branch
-- **Version**: Automatically uses version from `src/local_deep_research/__version__.py`
-- **Changelog**: Auto-generated from commit history since last release
-- **No duplicates**: Skips if release already exists for that version
+- **Trigger**: Push to `main` whose `__version__.py` resolves to a tag
+ that does not yet exist as a GitHub release. In practice this means
+ "merge a PR that bumps `__version__.py`". Tag pushes (`v*.*.*`) and
+ manual `workflow_dispatch` runs also trigger the pipeline and bypass
+ the version-exists check.
+- **Version**: Read from `src/local_deep_research/__version__.py` by
+ the `version-check` job; the tag is `v<version>`.
+- **Release body**: Composed by `.github/workflows/release.yml` from three sources:
+ 1. **AI TL;DR** generated by OpenRouter (`vars.AI_MODEL`).
+ 2. **Hand-written notes** from `docs/release_notes/<version>.md` — produced
+ from contributor-supplied `changelog.d/*.md` fragments by
+ `pdm run towncrier build` at release prep (see [Release-notes flow](#-release-notes-flow-towncrier-news-fragments) below).
+ 3. **Auto-generated PR list** from GitHub's generate-notes API,
+ label-categorized.
+- **No duplicates**: If a release for `v<version>` already exists, the
+ `version-check` job sets `should_release=false` and every downstream
+ job (security gate, CI gate, build, publish) is skipped.
### 2. **Automatic Publishing** (with approval)
- **GitHub Release** → triggers:
@@ -28,11 +50,26 @@ Code owners (defined in `.github/CODEOWNERS`):
### For Regular Releases:
-1. **Create PR** with your changes
-2. **Update version** in `src/local_deep_research/__version__.py`
-3. **Get approval** from code owners
-4. **Merge to main** → Release automatically created
-5. **Approve publishing** in GitHub Actions (PyPI/Docker)
+1. **Render news fragments** (run from repo root):
+ ```bash
+ pdm run towncrier build --version <X.Y.Z> --yes
+ ```
+ Towncrier writes `docs/release_notes/<X.Y.Z>.md` (per the
+ `{version}`-templated `filename` in `pyproject.toml`'s
+ `[tool.towncrier]`) and `git rm`s the consumed `changelog.d/*.md`
+ fragments. Preview first with `--draft` (writes nothing). Skip if no
+ fragments exist for this release — the workflow tolerates a missing
+ per-version file (warns and proceeds with auto-notes only).
+2. **Bump version** in `src/local_deep_research/__version__.py`
+3. **Commit both** in one go:
+ ```bash
+ git add src/local_deep_research/__version__.py docs/release_notes/<X.Y.Z>.md
+ git commit -m "chore(release): bump to <X.Y.Z> + render news fragments"
+ git push
+ ```
+4. **Open PR** if not on a release branch already, get approval from code owners
+5. **Merge to main** → Release automatically created
+6. **Approve publishing** in GitHub Actions (PyPI/Docker)
### For Hotfixes:
@@ -73,9 +110,66 @@ If automation fails:
2. **Contact code owners** for assistance
3. **Check workflow logs** in GitHub Actions
+## 📝 Release-notes flow (towncrier news fragments)
+
+Hand-written release notes are assembled from per-PR fragments using
+[towncrier](https://towncrier.readthedocs.io). This replaces the older
+shared `docs/release_notes/<version>.md` model, which broke down at
+LDR's PR throughput (multiple PRs/day racing for the same file).
+
+### Contributor side
+
+Each PR with user-visible behavior change drops one tiny markdown file:
+
+```
+changelog.d/<PR-number>.<category>.md
+```
+
+Categories: `breaking`, `security`, `feature`, `bugfix`, `removal`,
+`misc` (canonical list lives in `[[tool.towncrier.type]]` entries in
+`pyproject.toml`; the pre-commit hook reads it from there). Orphan
+fragments (no PR/issue number) use `changelog.d/+<slug>.<category>.md`.
+The pre-commit hook (`recommend-release-notes`) nudges contributors who
+add ≥20 source lines without a fragment, and validates filenames so a
+typo'd category doesn't silently vanish at render time. See
+[`changelog.d/README.md`](../changelog.d/README.md) for the full
+convention.
+
+### Maintainer side (release prep)
+
+```bash
+pdm run towncrier build --version <X.Y.Z> --yes
+```
+
+What towncrier does (configured in `pyproject.toml` under
+`[tool.towncrier]`):
+1. Reads fragments from `changelog.d/`.
+2. Writes the rendered output to `docs/release_notes/<X.Y.Z>.md` (per
+ the `{version}`-templated `filename`; `single_file = false` makes
+ this a per-release file rather than appending to a master CHANGELOG).
+3. `git rm`s the consumed fragments (deletion staged for commit).
+4. Stages the new release-notes file via `git add`.
+
+The release workflow (`.github/workflows/release.yml`) then `cat`s
+`docs/release_notes/<X.Y.Z>.md` into the published release body. If the
+file is missing (maintainer forgot to run towncrier), the workflow logs
+a warning and proceeds with the AI TL;DR + auto PR list only — no hard
+failure, but the hand-written narrative is lost.
+
+### Preview without committing
+
+```bash
+pdm run towncrier build --draft --version <X.Y.Z>
+```
+
+`--draft` renders to stdout without touching any files or fragments.
+Useful while iterating on a fragment locally.
+
## 📊 Release Checklist
+- [ ] News fragments rendered: `pdm run towncrier build --version <X.Y.Z> --yes`
- [ ] Version updated in `__version__.py`
+- [ ] Render + bump committed together
- [ ] Changes tested in PR
- [ ] Code owner approval received
- [ ] CI tests passing
diff --git a/pdm.lock b/pdm.lock
index 3fd4e9b705..cb534031cd 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
groups = ["default", "dev", "mcp"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
-content_hash = "sha256:8241834e2249220544021e5859682a650556c35827742049b33d1c24727e743e"
+content_hash = "sha256:26f04ed707a28e33fa02a76c5551336d78cc02db2733aea30d6b1496fa0f57ae"
[[metadata.targets]]
requires_python = ">=3.12,<3.15"
@@ -6226,6 +6226,24 @@ files = [
{file = "torch-2.10.0-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:f4bea7dc451267c028593751612ad559299589304e68df54ae7672427893ff2c"},
]
+[[package]]
+name = "towncrier"
+version = "24.8.0"
+requires_python = ">=3.8"
+summary = "Building newsfiles for your project."
+groups = ["dev"]
+dependencies = [
+ "click",
+ "importlib-metadata>=4.6; python_version < \"3.10\"",
+ "importlib-resources>=5; python_version < \"3.10\"",
+ "jinja2",
+ "tomli; python_version < \"3.11\"",
+]
+files = [
+ {file = "towncrier-24.8.0-py3-none-any.whl", hash = "sha256:9343209592b839209cdf28c339ba45792fbfe9775b5f9c177462fd693e127d8d"},
+ {file = "towncrier-24.8.0.tar.gz", hash = "sha256:013423ee7eed102b2f393c287d22d95f66f1a3ea10a4baa82d298001a7f18af3"},
+]
+
[[package]]
name = "tqdm"
version = "4.67.3"
diff --git a/pyproject.toml b/pyproject.toml
index ebc807da9c..85e5b1e4bd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -174,6 +174,7 @@ dev = [
"types-flask~=1.1",
"hypothesis~=6.151",
"vulture~=2.14",
+ "towncrier~=24.8",
]
[tool.pytest.ini_options]
@@ -394,3 +395,70 @@ module = [
"local_deep_research.web.*",
]
ignore_errors = true
+
+# ---------------------------------------------------------------------------
+# towncrier — release-notes news fragments
+# ---------------------------------------------------------------------------
+# Each PR drops a tiny markdown file under changelog.d/ named
+# <id>.<category>.md (or +slug.<category>.md for orphan fragments
+# without a PR/issue number). At release prep time the maintainer runs:
+#
+# pdm run towncrier build --version <X.Y.Z> --yes
+#
+# which renders the fragments into docs/release_notes/<X.Y.Z>.md (per
+# the {version}-templated filename below) and `git rm`s the consumed
+# fragments. The release workflow (.github/workflows/release.yml) then
+# reads that per-version file as the human-narrative input to the
+# release body (alongside the AI TL;DR and the auto-generated PR list).
+#
+# Categories are intentionally lean — the auto-generated PR list already
+# catches dep bumps, CI churn, etc., so changelog.d/ fragments are just
+# for user-visible changes worth highlighting.
+[tool.towncrier]
+package = "local_deep_research"
+package_dir = "src"
+# single_file=false + a {version}-templated filename makes towncrier
+# write a fresh per-release file each build instead of appending to one
+# growing CHANGELOG. Matches the pre-existing
+# docs/release_notes/<version>.md convention used by the release
+# workflow.
+single_file = false
+filename = "docs/release_notes/{version}.md"
+directory = "changelog.d"
+# title_format=false suppresses the `## <version> (<date>)` header in
+# the rendered output — the GitHub release page already shows the
+# version as its title, and per-version files don't need an inline
+# version header either.
+title_format = false
+issue_format = "[#{issue}](https://github.com/LearningCircuit/local-deep-research/pull/{issue})"
+underlines = ["", "", ""]
+
+[[tool.towncrier.type]]
+directory = "breaking"
+name = "💥 Breaking Changes"
+showcontent = true
+
+[[tool.towncrier.type]]
+directory = "security"
+name = "🔒 Security"
+showcontent = true
+
+[[tool.towncrier.type]]
+directory = "feature"
+name = "✨ New Features"
+showcontent = true
+
+[[tool.towncrier.type]]
+directory = "bugfix"
+name = "🐛 Bug Fixes"
+showcontent = true
+
+[[tool.towncrier.type]]
+directory = "removal"
+name = "🗑️ Removed"
+showcontent = true
+
+[[tool.towncrier.type]]
+directory = "misc"
+name = "📝 Other Changes"
+showcontent = true