Thanks to @ctrueden, the script_templates strategy (that we're already using) can now be generalized to any path. @m-entrup tested the new discovery mechanism and everything seems to work well, so we should ditch the legacy way of directory mirroring, in favor of the new mechanism, as noted by @imagejan.
I really want to implement this, but unfortunately, I may not have time to work on this immediately, so any PRs are welcomed!