Thanks to visit codestin.com
Credit goes to github.com

Skip to content

toolpath-convo: Write tool on existing file produces addition-only diff #35

@eliothedeman

Description

@eliothedeman

Follow-up from #34 review.

toolpath_convo::derive::file_write_diff handles the Write { content } shape by diffing against "" — i.e. emitting an all-+ hunk. That's honest for new files but misleading for overwrites, where a Write that replaced existing content will appear in the Path document as if the file didn't exist before.

The conversation JSONL doesn't capture prior state, so we can't reconstruct it from the log alone. Options:

  1. Consult git — when the derivation has access to path.base.uri (e.g. a file:// project path we already use for cwd), read git show HEAD:<relative-path> and diff against that. Best-effort; skip if not a git repo or path not tracked.
  2. Read the working tree at derivation time — the cwd is on disk; we can fs::read_to_string(path) to get the current state, which is the post-write state. Combined with git HEAD → pre-write state. Same as (1) from a different angle.
  3. Give up — document the asymmetry in file_write_diff's rustdoc and accept additions-only for content.

(1) is the richest answer but depends on having a git base; needs a clean fallback to (3) when absent.

Pointers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions