STS internally has a few hacks of its own to try and pry information out of Grails e.g. about dependencies. We wish there was a nice API to just ask Grails for this info, but unfortunately there isn't. This code/hacks are some of the most fragile pieces of STS/Grails tooling and cause us (me mostly a lot of headache.
We store this information in a file that is outside the project, in a place somewhere in the workspace metadata. Since it is outside the project, it won't be versioned (which is as it should be, as you point out).
We use this info to calculate the contents of the Grails Class Path container (i.e. the stuff you see under 'Grails Dependencies').
I tried a bit yesterday to play with your scripts. To be honest, I was a bit put-off by the amount of error messages and the very long time it took to execute the script. So, I'm not so sure now if would want to hookup the script directly from the STS UI.
However, if we were going to hook it up, the way I'd see it working would be that STS have a menu somewhere 'Download Source Attachements' or something like that. If the user selects it, it would execute the necessary grails commands. We'd pass the location of the file to you. We'd agree on some format (it needn't be complex, just a list of entries associating binary jars to their corresponding source / javadoc jars.
STS would read the file when the commands is completed and use the info in it to update the classpath container with source / javadoc attachements.