Condukt.Tools.Edit (Condukt v3.0.0)

Copy Markdown View Source

Tool for making surgical edits to a file, after pi's edit tool.

One call makes one or more replacements in one file. Each oldText is matched against the original file, not incrementally, must appear exactly once, and must not overlap another edit's.

Matching tolerates what models get wrong: line endings (CRLF files are matched as LF and keep their CRLFs), a byte order mark, and, when the exact text is not found, trailing whitespace, smart quotes, Unicode dashes, and special spaces. A fuzzy match rewrites only the lines it touches.

All filesystem access goes through the active Condukt.Sandbox: the tool reads the file, applies the edits, and writes it back. A session never runs two calls that change files at once, so nothing else writes the file in between.

Parameters

  • path - Path to the file to edit
  • edits - List of %{"oldText" => ..., "newText" => ...} replacements

A single oldText/newText pair (or old_text/new_text) at the top level is accepted as a one-element edits.

Summary

Functions

Callback implementation for Condukt.Tool.description/0.

Callback implementation for Condukt.Tool.name/0.

Callback implementation for Condukt.Tool.parameters/0.

Callback implementation for Condukt.Tool.replay_safe?/0.

Callback implementation for Condukt.Tool.replay_safe?/1.

Functions

description()

Callback implementation for Condukt.Tool.description/0.

name()

Callback implementation for Condukt.Tool.name/0.

parameters()

Callback implementation for Condukt.Tool.parameters/0.

replay_safe?()

Callback implementation for Condukt.Tool.replay_safe?/0.

replay_safe?(opts)

Callback implementation for Condukt.Tool.replay_safe?/1.