···11+<!--
22+SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
33+44+SPDX-License-Identifier: CC0-1.0
55+-->
66+77+# AGENTS.md
88+99+This file provides guidance to AI coding agents when working with code in this repository.
1010+1111+## Development Commands
1212+1313+- **Build**: `just build` (outputs binary as `formatted-commit`)
1414+- **Run during development**: `just run [flags]`
1515+- **Format code**: `just fmt`
1616+- **Update dependencies**: `go mod tidy`
1717+- **Test**: `go test ./...`
1818+1919+Example usage:
2020+2121+```bash
2222+just run -t feat -m "add validation" -T "Co-authored-by: Name <email>"
2323+```
2424+2525+## Project Purpose
2626+2727+This is a CLI tool that formats git commit messages according to Conventional Commits specification and pipes them directly to `git commit -F -`. It enforces:
2828+2929+1. Subject length: max 50 characters in format `type(scope): message`
3030+2. Body wrapping: strictly 72 columns using Markdown formatter
3131+3. Trailer validation: follows git's trailer specification
3232+3333+## Architecture
3434+3535+Single-file CLI application (`main.go`) using:
3636+3737+- **cobra**: CLI framework for flags and commands
3838+- **fang**: Charmbracelet's execution wrapper (provides version handling, etc.)
3939+- Future: Will need a Markdown formatter for body text (likely from Charmbracelet ecosystem based on dependencies)
4040+4141+## Critical Implementation Details
4242+4343+### Subject Validation (50 char limit)
4444+4545+The subject is constructed as `type(scope): message` or `type: message` (when scope is empty). Breaking changes add a `!` after the type/scope like `type(scope)!: message`.
4646+4747+When validation fails, clearly mark where the subject exceeds 50 characters in error output.
4848+4949+### Body Formatting
5050+5151+The body (`-b` flag) must be:
5252+5353+1. Sanitised because it should only be basic text and bullets
5454+2. Formatted as Markdown, properly wrapping bullets with hanging indents on
5555+ following lines like this
5656+3. Strictly wrapped to 72 columns using a pure-Go formatter
5757+4. Separated from subject by one blank line
5858+5. Separated from trailers by one blank line
5959+6060+### Trailer Formatting (Critical)
6161+6262+Trailers follow git's specification precisely:
6363+6464+- Format: `Key: value` (newline-delimited pairs)
6565+- No whitespace before or inside the key
6666+- Any number of spaces/tabs allowed between key and separator `:`
6767+- Values can be multiline with continuation lines starting with whitespace (RFC 822 folding)
6868+- The trailer group must be:
6969+ - At the end of input, OR
7070+ - The last non-whitespace lines before a line starting with `---`
7171+ - Preceded by one or more empty/whitespace-only lines
7272+7373+Example valid trailer:
7474+7575+```
7676+Co-authored-by: This is a very long value, with spaces and
7777+ newlines in it.
7878+```
7979+8080+### Flag Nuance
8181+8282+- `-B` / `--breaking`: Boolean flag for breaking changes (adds `!` to subject)
8383+- `-b` / `--body`: String flag for commit body text
8484+- `-T` / `--trailer`: Repeatable flag for trailers
8585+8686+### Final Output
8787+8888+The formatted commit message must be piped to `git commit -F -` to read from stdin.