Mark Alldritt has released an aequery tool.
For example:
aequery '/Keyboard Maestro/macro'
Will return a list of all the macro IDs as XPaths (note - singular macro not plural macros).
I haven't looked in to it in more details, but it looks like the sort of tool that could be quite useful in some circumstances for controlling applications.