{"modulePath":"github.com/Agent-Field/codeaf","version":"v0.8.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package patch\n\nPackage patch is the exact-match text editor behind \\`codeaf patch\\`: one old text in, the file with its single occurrence replaced out.\n\nThe law it keeps is the edit hand's (internal/exec/bare), which cannot be imported from here: an exact match is counted in line-ending-normalized space, so a caller who typed their old text with the endings their terminal shows still edits a CRLF file, and a replacement is refused rather than guessed at when the text matches nothing or matches several places at once. A shell has no model to ask for more context, so the refusals name the count — \"found 3 matches\" is something a person can act on, and a silent first-match replacement is not.\n\n## Functions\n\n```go\nfunc Apply(content, oldText, newText string) (string, error)\n```\nApply replaces the ONE occurrence of oldText in content with newText.\n\nMatching is exact after three normalizations the edit hand also makes: a leading byte-order mark is set aside (a shell will not include one in the text it passes), every line ending is folded to LF (so LF text edits a CRLF file), and the replacement is written back with the file's own ending. The match is a plain substring count after that folding — no fuzzy fallback, because a person typing a patch into a shell wants either the edit they described or a refusal, and a \"close enough\" match would apply the wrong one.\n\nThe returned error carries the count when the match is not exactly one: none, or two or more. Content is only returned when the edit was made.\n\n","path":"github.com/Agent-Field/codeaf/internal/patch","name":"patch","synopsis":"Package patch is the exact-match text editor behind `codeaf patch`: one old text in, the file with its single occurrence replaced out.","isRedistributable":true}
