pi-apply-patch Includes grammar, test fixtures, and TypeScript adaptations of the parser, sequence matcher, and file update algorithm from OpenAI Codex. Copyright 2025 OpenAI Licensed under the Apache License, Version 2.0 (see LICENSE). Upstream: https://github.com/openai/codex Revision: b04a2c264516ec2e6b3c91dd73ad18a21fd5a88f Sources: codex-rs/apply-patch/ and codex-rs/core/assets/tools/apply_patch.lark Modifications: the parser and update algorithm are expressed as synchronous TypeScript functions. Local adaptations preserve a file-leading BOM, unchanged context text, blank lines, and LF/CRLF endings, and provide bounded diagnostics for Unicode, whitespace, and blank-line differences. Execution is adapted to pi, with workspace boundary checks, filesystem injection, mutation queues, and plain tool results. Deterministic format normalization precedes strict parsing; input repairs and execution warnings share a model-visible notice channel. Multi-environment routing and the upstream experimental PreserveLineEndings implementation are not included.