A normal git diff gets messy once the agent changes several files for different reasons. Grouping the change into “chapters” seems like the right idea.
Do you infer those chapters only from the diff, or can you also use the agent’s original plan/task history?