American here. Not an atty.
That said…
Courts don’t have time or interest to explore personality or psychology. They always deal with conflict, so nothing about your situation will seem unusual.
You need to focus on the law.
Was anything in your messages illegal? Threatening?
Do you have any evidence that anything she did or said to you in those prior months was illegal or threatening? I mean real, admissible evidence. Any witnesses?
If there is no evidence, then what is the basis for her claim?
What are the charges you’re facing? What is the outcome you’re hoping for?
Do you have an atty?
Assuming that you do, here are some things to explore:
Depose your ex, get her to acknowledge the history you mention here under oath. Then present in court. Watch her get tangled in her own story.
Do you know your ex’s triggers? Review with your atty. A good litigator will know how to get your ex to expose herself while in court. I bet she’s prone to tantrums - help her have one in court…
The idea is to avoid making unsubstantiated claims, ie “she’s got a PD and is mentally unstable” - this is opinion, not fact, hard to prove, and therefore not helpful to your case. Forget about this.
Instead, get her to demonstrate her behavior to the court on her own…. Show the court who is reasonable and who is not.
Then politely apologize to the judge or magistrate for wasting their time with your unfortunate but not-unlawful situation, and ask for permission to go your separate ways...
Make sense?