You really don't want to do that with PG. Keeping your patches rebased will be a huge pain.
Use LLMs.
No, not for that.
For anything, they probably excel at these sort of tasks.
I use https://gist.github.com/nicowilliams/ea2fa2b445c2db50d2ee650... for this.
You could expose this as a tool for an LLM.