Files
sic/contrib/sicedit
T
Markus Fritsche dd987e4c1e contrib: sic companion helpers (lmcp-tool, sicwrite, sicedit)
lmcp-tool drives a host's lmcp (MCP) tools over a stateless tools/call via sic —
list for discovery, key=value args so a model never embeds JSON in a shell (apostrophe-safe).
sicwrite/sicedit pass file content as argv since sicd consumes stdin for the frame.
References the lmcp server project: git.reauktion.de/marfrit/lmcp

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWpfhDgYNA21tETDP9ueBE
2026-07-19 20:36:05 +02:00

14 lines
556 B
Bash
Executable File

#!/bin/sh
# sicedit <path> <old> <new> — replace the single exact occurrence of <old>
# with <new> in <path> (edit_file semantics). Args pass losslessly via sic.
[ $# -ge 3 ] || { echo "usage: sicedit <path> <old> <new>" >&2; exit 2; }
python3 - "$1" "$2" "$3" <<'PY'
import sys
p,o,n=sys.argv[1],sys.argv[2],sys.argv[3]
s=open(p).read()
c=s.count(o)
if c==0: sys.stderr.write("sicedit: old_string not found\n"); sys.exit(1)
if c>1: sys.stderr.write("sicedit: old_string not unique (%d matches)\n"%c); sys.exit(1)
open(p,'w').write(s.replace(o,n,1))
PY