Skip to content

feat: detect perl/ruby/awk in-place edits (#46 follow-up)#76

Merged
Cannon07 merged 1 commit into
mainfrom
feat/inplace-edit-detect
Jun 5, 2026
Merged

feat: detect perl/ruby/awk in-place edits (#46 follow-up)#76
Cannon07 merged 1 commit into
mainfrom
feat/inplace-edit-detect

Conversation

@Cannon07
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 commented Jun 5, 2026

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 existing sed -i:

  • perl / ruby -i — including clustered forms (-0pi, -pie), backup suffix (-i.bak), and bundled -e (-pe).
  • gawk -i inplace.
  • Requires the in-place flag, so read-only one-liners (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

…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>
@Cannon07 Cannon07 merged commit 6dbc60f into main Jun 5, 2026
3 checks passed
@Cannon07 Cannon07 deleted the feat/inplace-edit-detect branch June 5, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant