Scripting rich text using DEVONthink (or TextEdit) is definitely possible, see Scripts > Format for example. At least when using AppleScript
Some smart templates (e.g. Daily Journal - Text) internally script rich text too. And it’s not limited to visible rich text documents, see e.g. Scripts > Edit > * Replace Text in Documents…