That used to be a problem, but Claude Code has been doing fine at it for a few months now.
<line>: <s-expr .-separated path>
then eg when passed 'replace 2.1 "(+ x y)"' it returns a new file (as a list of s-exprs).
Do you have something in a public repository I can look at?