feat: detect perl/ruby/awk in-place edits (#46 follow-up)#76
Merged
Conversation
…w-up) Codex (and other GPT-class agents) edit files via `perl -0pi -e '…' file`, which the detector didn't recognise, so no neo-tree indicator fired. Add an in-place-editor matcher alongside `sed -i`: - perl/ruby `-i` (incl. clustered -0pi/-pie and -i.bak; -e/-E may be bundled) - gawk `-i inplace` - requires the in-place flag, so read-only one-liners aren't flagged. These use a new quote-aware POSIX tokeniser rather than the char-walk/redirect scanners, because in-place scripts routinely contain `;`/`|` (e.g. `perl -pi -e 's/a/b/; s/c/d/'`) that those would mis-cut. The tokeniser treats newlines as command separators too, so a multi-line command can't bleed later words into the file list. 14 new spec rows (real codex sample, multi-statement, multiple files, bundled flags, ruby/awk, sudo, chains, read-only negatives). Full suite green on macOS. CONTEXT.md Tier-1 entry updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Follow-up to #75. Closes a Tier-1 detection gap a real agent hit: Codex edits files via in-place editors like
perl -0pi -e '…' README.md, which the detector didn't recognize, so no neo-tree change indicator fired.What it adds
An in-place-editor matcher in
shell_detect, sibling to the existingsed -i:-i— including clustered forms (-0pi,-pie), backup suffix (-i.bak), and bundled-e(-pe).-i inplace.perl -ne 'print' f,awk '{print}' f) are not flagged.These run through a new quote-aware POSIX tokenizer rather than the char-walk/redirect scanners, because in-place scripts routinely contain
;/|(perl -pi -e 's/a/b/; s/c/d/') that those would mis-cut. The tokenizer also treats newlines as command separators, so a multi-line command can't bleed later words into the file list.Targets flow through the same
finalise(clean → resolve →looks_like_path→ transient filter) as every other write source, so the OS path adapter, dedup, and Tier-1 semantics (bash_*origin prefix, indicator-only) are unchanged.Tests
14 new spec rows: the real Codex sample, multi-statement scripts (
;in the script), multiple files,-i.bak, bundled-pie,ruby -i -pe,gawk -i inplace,sudo perl,&&chains, and read-only negatives. Full Lua suite green on macOS (154 tests). The grammar is OS-agnostic; path resolution is already covered per-OS.Scope
POSIX-grammar enhancement only — no Windows-specific or pipeline changes. The earlier-noted heredoc false-positive (from
each_subcommand's newline split) is a separate matcher and untouched here; can be a later pass if it bites.🤖 Generated with Claude Code