For scripts, I propose to use a unified directory for caching. A cache location for
my-script.swift, for example, may be
~/.swiftpm/scripts/my-script-abc123, which will contain the
abc123 is a hash value computed against the real path of the script.
Such design can prevent scripts from producing scattered wastes, and enable centralized control over build caches. This will allow scripts to be moved easily throughout the system.
swift script cleanup can remove the cache for scripts that no longer exist.