Jumping in here... I've been busy on other things, so I haven't been on the forum recently.
I tried to skim this thread to see what you needed, but I'm not patient enough, I guess. If you can summarize what you're trying to do, I might be able to help. I'm really good at parsing plists, using JXA.
first of all I hope you don't mind that I use your RL name.
I've read and seen a lot of stuff you did here in the past and I love the almond of skills you have
I like your approach combining JXA and XQuery (don't know anything about XQuery but its on my things I'd love to learn in the future) - but since I am trying to learn JXA it is hard for me to understand your code - but I try.
From what I understand - correct me If I am wrong - It lists ALL Macros whether they are enabled or disabled. but this is only one part of what I would need to have - if I would use your code.
Since this approach refers to my Idea grabbing Macros Automatically in a Spotlight Search Macro for the given App that is at front in conclusion with Apps whose are running in the background that I use in the intercommunicative way together - I need to have a Script that looks for
uses the Group Name or multiple ones
only the enabled Macros
strips out the Macro which uses that Script
lists them line by line in MacroName=MacroUUID
Why this is needed ? Because I have a lot Macros & Groups in My Setup whose Enable only those that are needed and Disable those that aren't needed in a conditional manner including even the check on which Mac they are running or are needed.
That is for this.... speaking now of AppleScript and the Basic Idea parsing out the MacroUUID defined by The Group's Name and the Desired Macro's Name as iput for the code that has to do the work giving me the UUID.
Do you eventually can help me there ?? - If so please consider that I want to put the code in a Handler for a Script Library.
This is the bit I still don't understand. Why do you need the UUID? If you know the name, and the name is unique among your currently enabled macros, you can use the name in kmtrigger. If the name isn't unique among your currently enabled macros, how do you chose the correct item from a list of names?
 This was after some very quick tests, so I'm quite happy to be corrected if, somehow, kmtrigger triggers both enabled and disabled macros
In this special Case The format has to be set like this due to the Original Code of Dan's Spotlight Search Prompt Macro which can be set up by Hand for a specific use case or should be grabbed by the use of a Script.