codex_patch.cr v0.5.0
codex_patch.cr
Crystal shard that implements the Codex patch format — a stripped-down, file-oriented diff format designed to be easy to parse and safe to apply, designed for use by LLMs.
Usage
- Add the dependency to your
shard.yml:
dependencies:
codex_patch:
github: nogginly/codex_patch.cr
-
Run
shards install -
Import the shard and use the top-level
CodexPatch.applymethod with with anIO(orString) to apply a patch to the current working directory.
require "codex_patch"
abort("Specify patch file, or - to read from standard inpput.") if ARGV.size.zero?
patch_file = ARGV.first
File.open(patch_file, "r") do |patch_io|
cwd = Dir.current
CodexPatch.apply(patch_io, cwd) do |event|
puts event.inspect
end
end
CLI
See DEVELOPMENT.md for how to build the CLI.
The included apply_codex_patch command applies a patch file to a target directory:
apply_codex_patch PATCH_FILE [ TARGET_DIR ]
Apply a codex patch to files in TARGET_DIR (defaults to the current directory).
PATCH_FILE must be a valid codex patch created by CodexPatch.
Patch file format
The document is intentionally separate so that you can give it to your LLM of choice to teach it how to write these patch files when using apply_codex_patch with your coding agent.
Contributions, by invitation!
With apologies, at this time contributions are by invitation only and limited to people I know and see often.
These are early days for codex_patch.cr and I am busy with family and work.
At this time I want to work on this at a manageable pace.
codex_patch.cr
- 0
- 0
- 0
- 0
- 1
- about 4 hours ago
- July 17, 2026
Mozilla Public License 2.0
Fri, 17 Jul 2026 23:29:49 GMT