# git-cliff configuration for GuruConnect
# Conventional-commits preset, grouped by feat / fix / perf.
# Used by .gitea/workflows/release.yml to generate CHANGELOG.md and per-component changelogs.
# Docs: https://git-cliff.org/docs/configuration

[changelog]
# Header rendered once at the very TOP of CHANGELOG.md. The release workflow regenerates the
# whole file over full history with `--output`, so this fixed preamble is always the first thing
# in the document, above the newest version block.
header = """
# Changelog

All notable changes to GuruConnect are documented here. Format follows
[Keep a Changelog](https://keepachangelog.com/); the project uses semantic versioning.

Per-version entries below are generated from conventional commits (`feat:`, `fix:`, `perf:`)
by the release workflow; per-component changelogs are also written to
`changelogs/<component>/v<version>.md` and served at `/api/changelog/...`.
"""

# Body template for each release. Designed to render a single version block that the workflow
# reuses verbatim (via `--strip header`) for the per-component changelog files.
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [Unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}{% if commit.id %} ({{ commit.id | truncate(length=8, end="") }}){% endif %}\
{% endfor %}
{% endfor %}\n
"""

trim = true

# Footer rendered once at the BOTTOM of CHANGELOG.md, after the newest-first version blocks. The
# initial [0.1.0] release predates conventional-commit history and cannot be re-derived from the
# git log, so it is carried here verbatim. Result over full history is:
#   header (# Changelog preamble) -> [newest .. ] version blocks (newest first) -> [0.1.0] footer.
footer = """
## [0.1.0] - 2026-01-18

### Added
- Initial GuruConnect: Rust agent (DXGI/GDI capture, input injection, native viewer,
  `guruconnect://` handler), Axum relay server, protobuf-over-WSS transport.
- Phase-1 security hardening (JWT, Argon2id, rate limiting, security headers, SEC-1..5),
  systemd units, automated backups.
"""

[git]
# Parse commits as conventional commits.
conventional_commits = true
filter_unconventional = true
split_commits = false

# Group commits into changelog sections. Anything not matched is skipped (chores, docs, etc.).
commit_parsers = [
    { message = "^feat", group = "Added" },
    { message = "^fix", group = "Fixed" },
    { message = "^perf", group = "Performance" },
    { message = "^revert", group = "Reverted" },
    { message = "^chore\\(release\\)", skip = true },
    { message = "^chore: release", skip = true },
    { message = "^chore", skip = true },
    { message = "^docs", skip = true },
    { message = "^test", skip = true },
    { message = "^ci", skip = true },
    { message = "^build", skip = true },
    { message = "^style", skip = true },
    { message = "^refactor", skip = true },
    { body = ".*security", group = "Security" },
]

# Skip release-bump commits so they never appear in the changelog.
filter_commits = false

# Process tags matching vMAJOR.MINOR.PATCH.
tag_pattern = "v[0-9]*"

# Sort newest first.
sort_commits = "newest"
