The Myers trace stores O(D) snapshots of an O(D)-wide vector, so the edit
distance D drives O(D²) ≈ O(N²) time and memory: a full rewrite of a 3000-line
file allocated ~565 MB, ~6 GB at 10k lines — enough to OOM the synchronous
write-preview/checkpoint diff. Cap D at 2000 edits: small changes converge well
below it (so a tiny edit in a huge file still gets a real diff), while a near-
total rewrite falls back to cheap order-insensitive tallies and an omitted-diff
marker instead of a gigabyte allocation. A 6000-line rewrite now costs 63 MB.
Four reusable harness capabilities a desktop front-end needs, all additive and
independent of the agent loop / TUI (agent.go, chat_tui.go, cli.go untouched):
- diff: Myers line-diff engine (internal/diff) + a tool.Previewer optional
capability. write_file/edit_file/multi_edit can now compute the change a call
WOULD make (unified diff, +N/-M, create/modify) without touching disk, for
approval cards and changed-files panels. A consistency test asserts the
preview matches what Execute persists, so the two can't drift.
- inspect: read-only projection of providers (with key readiness), tools
(builtin vs mcp, read-only, previewable, schema), MCP servers/prompts/
resources, and slash commands into JSON-ready structs for a settings UI.
- config: programmatic, validated mutation surface (SetDefaultModel,
Upsert/RemoveProvider, SetPlannerModel, permission-rule edits, Upsert/
RemovePlugin) plus an atomic SaveTo, separate from the init wizard.
- builtin.Workspace: binds the built-in tools to a working directory so
concurrent agents (e.g. desktop tabs on different projects) get independent
path roots. A zero workDir is byte-identical to today's process-cwd behavior.