#File Edits

1 messages Β· Page 1 of 1 (latest)

raw laurel
#

TIL file edits are not a solved problem. There are entire startups just for that.

#

We need at the very least a search/replace tool, and possibly diff apply - brute write-file() is expensive and unreliable.

But that's just one step.

solar echo
#

Diff apply would be epic

#

I'll implement it my workspace!

#

I'll do search/replace just for completeness too

#

Code workspaces probably need a full ast lookup? Maybe?

raw laurel
#

What I've been told:

  • diff is the best you can do whith general model. it works but it's slower than a specialized model
  • I was also told "the top success for diff is 85% per aider benchmark"
  • cursor & others most likely use specialized models
  • startups like replace.ai offer proprietary models
static current
#

yes, also related: https://aider.chat/docs/unified-diffs.html

I've seen that the avante.nvim maintainer implemented that to add similar "cursor planning mode like" to avante.

ref: https://x.com/yetone/status/1891878146779345248

β€Œβ€Œβ€Œβ€Œβ€Œβ€ŒThe most painful part of developing this feature was figuring out how to perform a streaming diff between the code being generated and the original code during the applying process. I looked into VSCode's Copilot, and it turns out that it waits until the code is completely

jade sequoia
#

I'm running into a problem with my write_file() tool

#

it looks like it messes up when writing < or > back to a file

#

example:

162 : [2.2s] |          books = get_books(test_db)
162 : [2.2s] | -        assert len(books) >= 2
162 : [2.2s] | +        assert len(books) e 2
#

and then in the next step when the test tool runs it dies with an invalid character type error

#

also it doesn't happen every time, but when it does it is always with angle brackets

#

short of removing that assertion from the test suite entirely, any ideas on how to fix it? it's knocking my agent off course whenever it happens

jade sequoia
#

This was also happening with &

#

fwiw I was able to dramatically reduce the occurrence of this error by keeping the file below 100 lines of code

solar echo
#

Yeah that makes a huge difference. That's exactly why partial reads+writes are so effective for workspaces. We don't have to keep reading/writing entire files and adding that to the history

solar echo
raw laurel
#

@solar echo dag/ is the new daggerverse/? πŸ™‚

solar echo
#

I'm trying to move from dagger-modules/ to dag/ because it's shorter and I still like monorepos for utility modules

#

and it's just a bucket of dags πŸ™‚

solar echo
#

It's trying to use it and everything looks good, but I keep getting malformed patch errors 😞

#

i'll try git apply instead of patch

#

Same issue. I wonder if there's some bad characters hiding in there

raw laurel
#

I wonder if there's an even "dumber" option that's just line-replace, or search-replace (I think @glass anvil showed me the official MCP file edit server by Anthropic uses search replace)