If you can check the debuffs, and also get the counters of the debuffs, you could just let autocleric decide which debuff to use. (If you rightlick an debuff, you get the info you need - which resist and number of counters). You only need to add an list of debuffs which shall not be cured.
Since you know which spells the cleric uses and how many counter each spell cures it should not be that hard to write an logic which determines the best spell to cure the debuff, without really need to know what debuff it is.