stash: replace all `write-tree` child processes with API calls