Skip to content

phase3/modify-replace-in-file: regex replace-in-file verb - #103

Open
URaux wants to merge 4 commits into
phase2/w2from
phase3/modify-replace-in-file
Open

URaux wants to merge 4 commits into
phase2/w2from
phase3/modify-replace-in-file

Conversation

@URaux

@URaux URaux commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds planReplaceInFile(projectRoot, req) in src/lib/modify/replace-in-file.ts returning a RenamePlan-shaped result with character-offset edits (no disk writes)
  • Uses two separate RegExp objects (execRegex always-global for exec loop, replaceRegex non-global for replacement computation) to avoid infinite-loop from lastIndex reset
  • Exports InvalidPatternError and FileNotFoundError typed error classes
  • Extracts shared interfaces into src/lib/modify/types.ts
  • Wires replace verb into the modify handler with filePath/pattern/replacement/flags extraction
  • 10 vitest tests: literal replace-all, capture groups, gi/gm flags, no-match conflict, invalid pattern, invalid flags, file-not-found, absolute path, default-global behavior

Test plan

  • npx vitest run tests/lib/modify/replace-in-file.test.ts — 10/10 passed in 3.34s

🤖 Generated with Claude Code

URaux and others added 4 commits April 27, 2026 00:30
Adds noise-suppression lists to policy.drift. Block/container/edge IDs in
the ignore lists get filtered out of every bucket before drift is reported.
Pure function; never mutates input. clean flag is recomputed after filtering.

Use case: auto-generated blocks (cache layers, codegen output, archived
containers) that legitimately drift but shouldn't trigger PR comments.

5 tests covering: pass-through when no lists set, multi-bucket filtering,
container+edge filters, clean recomputation, no-mutation invariant.
Adds scripts/drift-stats.mjs that reads a folder of drift snapshot JSON
files and prints per-week avg/median/max drift counts and top-N most-drifted
blocks. Supports --last N, --top N, --format md|json. 10 tests covering
empty dir, populated multi-week, --last capping, and top-N block ranking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds planReplaceInFile() with InvalidPatternError/FileNotFoundError,
10 vitest tests (literal, capture groups, flags, no-match, error cases),
and wires the replace verb into the modify handler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Supports function/class/const/interface/type/enum. Idempotent when
already exported. Returns conflict on missing file or symbol.
7 tests covering all declaration kinds, idempotency, conflict cases.
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