I've had decent results telling agents to use emacs for structural editing operations. Pretty rare that I need to move a function across files verbatim but that should only be a few extra lines of elisp.