Skip to content
This repository was archived by the owner on Nov 9, 2026. It is now read-only.

fix(mcp-filesystem): preserve literal edit replacement text - #1979

Open
dvd233 wants to merge 1 commit into
bytedance:mainfrom
dvd233:codex/fix/mcp-filesystem-literal-edit-1976
Open

dvd233 wants to merge 1 commit into
bytedance:mainfrom
dvd233:codex/fix/mcp-filesystem-literal-edit-1976

Conversation

@dvd233

@dvd233 dvd233 commented Sep 20, 2026

Copy link
Copy Markdown

Summary

Fixes #1976

edit_file passed newText directly to JavaScript's String.replace, so $&, $$, $', and `$`` were interpreted as replacement patterns instead of being written literally. This could silently preserve the old text, remove dollar signs, or duplicate surrounding content.

The exact-match path now uses a replacement callback, which returns the requested text verbatim. The existing line-by-line fallback is unchanged.

Verification

  • Added MCP in-memory regression coverage for ordinary text, $&, $$, $', and `$``.
  • Covered sequential edits and dryRun behavior.
  • pnpm --filter @agent-infra/mcp-server-filesystem test — 5 passed.
  • pnpm exec prettier --check and pnpm exec eslint on changed files — passed.
  • pnpm exec tsc -p packages/agent-infra/mcp-servers/filesystem/tsconfig.json --noEmit — passed.
  • Built @agent-infra/logger, mcp-http-server, and @agent-infra/mcp-server-filesystem in dependency order; ESM, CJS, and declaration output succeeded.
  • git diff --check — passed.

Checklist

  • Added or updated necessary tests.
  • Updated documentation to align with changes (not applicable; no user-facing API text changed).
  • Verified no breaking changes.
  • My change does not involve the above items.

AI assistance

Codex assisted with issue investigation and test design. The submitted implementation and every changed line were reviewed against the issue, repository conventions, and the validation results above.

@netlify

netlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for agent-tars-docs canceled.

Name Link
🔨 Latest commit 320874e
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/6ab04fe121fe830008297f6c

@netlify

netlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tarko canceled.

Name Link
🔨 Latest commit 320874e
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/6ab04fe173a8bc000733732b

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report]: filesystem edit_file interprets literal replacement text as JavaScript replacement patterns

1 participant