MCPcopy Create free account
hub / github.com/shareAI-lab/learn-claude-code / run_edit

Function run_edit

agents/s12_worktree_task_isolation.py:524–533  ·  view source on GitHub ↗
(path: str, old_text: str, new_text: str)

Source from the content-addressed store, hash-verified

522
523
524def run_edit(path: str, old_text: str, new_text: str) -> str:
525 try:
526 fp = safe_path(path)
527 c = fp.read_text()
528 if old_text not in c:
529 return f"Error: Text not found in {path}"
530 fp.write_text(c.replace(old_text, new_text, 1))
531 return f"Edited {path}"
532 except Exception as e:
533 return f"Error: {e}"
534
535
536TOOL_HANDLERS = {

Callers 1

Calls 1

safe_pathFunction · 0.70

Tested by

no test coverage detected