Repository navigation
fix(github-copilot): enforce apply_patch writes from Codex models - #84
Open
rudratoshs wants to merge 1 commit into
Open
rudratoshs wants to merge 1 commit into
rudratoshs wants to merge 1 commit into
Conversation
Codex models running inside Copilot CLI send edits as apply_patch, but
the github-copilot adapter only modelled bash/create/edit. An apply_patch
payload fell through to the passthrough branch and became a no-op command,
so enforceTdd() and file-scoped rules never saw the write — TDD blocking
that works for Claude models was silently bypassed for Codex ones.
Model apply_patch in the copilot adapter, mirroring the codex adapter:
split the patch into one write action per file so files 2..N are not
skipped by path-scoped rules, and exclude apply_patch from passthrough so
a malformed patch surfaces as a parse error rather than passing through.
The per-file split is shared via a new vendors/apply-patch module so both
adapters stay identical. The raw patch text arrives as toolArgs (as
captured from the hook); an { input } object form is accepted too.
Closes nizos#56
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
Codex models running inside GitHub Copilot CLI send file edits as
apply_patch, but thegithub-copilotadapter only modelledbash/create/edit. Anapply_patchpayload therefore fell through to the passthrough branch and was treated as a no-op command, soenforceTdd()and file-scoped rules never saw the write. TDD blocking that works for Claude models was silently bypassed for Codex ones — matching the report in #56.What changed
apply_patchin the copilot adapter, mirroring the existingcodexadapter: split the patch into one write action per file (so files 2..N aren't skipped by path-scoped rules or per-fileenforceTdd), and addapply_patchto the passthrough exclusion list so a malformed patch surfaces as a parse error instead of passing through silently.src/vendors/apply-patch.tsand use it from both the codex and copilot adapters, so the two stay identical (same pattern as the existing sharedapply-edit.ts).toolArgs(as captured from the Copilot hook in--agent github-copilotmisses Codexapply_patchwrites (Claude path works) #56). An{ input }object form (object or JSON-string) is also accepted, mirroring the string→object moveobjectOrJsonStringalready handles for the other tools.Tests
Added to
github-copilot/adapter.test.ts: single-file apply_patch → write action, multi-file split → one write per file,{ input }object form, and a headerless patch → parse error. I confirmed the new tests fail onmain(the writes pass through unchecked) and pass with the fix. Fullnpm run checksis green (lint, format, typecheck, 554 tests, build).Note
Scope is deliberately limited to the enforcement (
parseAction) path that #56 reports. History reconstruction (event.ts) doesn't special-caseapply_patchfor the codex adapter either, so I left that untouched for parity rather than widening this change.Closes #56