René's URL Explorer Experiment


Title: fix(edit): 修复 LLM 转义错误时 loose_escape 回退路径写入错误内容的问题 by fym998 · Pull Request #136 · lessweb/deepcode-cli · GitHub

Open Graph Title: fix(edit): 修复 LLM 转义错误时 loose_escape 回退路径写入错误内容的问题 by fym998 · Pull Request #136 · lessweb/deepcode-cli

X Title: fix(edit): 修复 LLM 转义错误时 loose_escape 回退路径写入错误内容的问题 by fym998 · Pull Request #136 · lessweb/deepcode-cli

Description: 问题 LLM 在处理 LaTeX、JSON、Unicode 转义等场景时经常多数/少数反斜杠(如 \alpha 写成 \\alpha ),导致精确匹配失败进入 loose_escape 回退路径。该路径虽然能定位到正确的匹配位置,但直接使用 LLM 原始 newString(同样带有转义错误)写入文件,造成静默数据损坏——每次此类替换都会在文件中 引入错误的反斜杠数量。 解决方案 新增 fixNewStringEscaping() 确定性修正:通过比对 oldString 与匹配文本中各反斜杠组的数量比例,推导出 newString 的正确转义形式。覆盖 uniform ratio(均匀比例,如 LaTeX 命令)、zero ratio(引号转义→无转义)等情况。 优先确定性修正,LLM 兜底,节约成本:先用确定性算法修正。仅在转义比例不一致(mixed ratios,如同一字 符串中不同位置的反斜杠错误倍数不同)时,才调用 LLM 辅助判断。这样可以节约又贵又慢的 LLM 调用。 无法修正时明确报错而非静默写入:当确定性修正失败且 LLM 不可用时,返回明确错误信息,引导 LLM 重新读取文件或改用 Bash 工具。 测试覆盖(36 个测试全部通过) 场景 路径 LaTeX 命令 over-escaping(uniform ratio) 确定性修正 → loose_escape Unicode 转义 over-escaping(uniform ratio) 确定性修正 → loose_escape JSON 字符串转义 确定性修正 → loose_escape 引号转义→无转义(zero ratio) 确定性修正 → loose_escape 新串多出反斜杠组(reuse last ratio) 确定性修正 → loose_escape LaTeX 混合转义(mixed ratios) 确定性失败 → LLM 修正 JS Unicode 混合转义 确定性失败 → LLM 修正 JSON 混合转义 确定性失败 → LLM 修正 混合转义 + 无 LLM 确定性失败 → 返回错误 ok: false

Open Graph Description: 问题 LLM 在处理 LaTeX、JSON、Unicode 转义等场景时经常多数/少数反斜杠(如 \alpha 写成 \\alpha ),导致精确匹配失败进入 loose_escape 回退路径。该路径虽然能定位到正确的匹配位置,但直接使用 LLM 原始 newString(同样带有转义错误)写入文件,造成静默数据损坏——每次此类替换都会在文件中 引入错误的反斜杠数量。 解决方案 新增 ...

X Description: 问题 LLM 在处理 LaTeX、JSON、Unicode 转义等场景时经常多数/少数反斜杠(如 \alpha 写成 \\alpha ),导致精确匹配失败进入 loose_escape 回退路径。该路径虽然能定位到正确的匹配位置,但直接使用 LLM 原始 newString(同样带有转义错误)写入文件,造成静默数据损坏——每次此类替换都会在文件中 引入错误的反斜杠数量。 解决方案 新增 ...

Opengraph URL: https://github.com/lessweb/deepcode-cli/pull/136

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ca44aa0e-6253-9764-61a3-1c799bb776f0
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC6E8:19E229:D48AB3:125BF02:6A4DCD40
html-safe-nonce0018e93957d50a2df64b4b4f16412c65de41388c09ba6c0c5a76e51432de7b84
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkU4OjE5RTIyOTpENDhBQjM6MTI1QkYwMjo2QTREQ0Q0MCIsInZpc2l0b3JfaWQiOiI0MTA3MDc5MDg3MjIyMDE3MzQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6a8d5683f9572a8d1ab5f5069e7313f2c6c066c446d82ae3dc94dda877c79858
hovercard-subject-tagpull_request:3773089310
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/lessweb/deepcode-cli/pull/136/files
twitter:imagehttps://avatars.githubusercontent.com/u/61316972?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/61316972?s=400&v=4
og:image:alt问题 LLM 在处理 LaTeX、JSON、Unicode 转义等场景时经常多数/少数反斜杠(如 \alpha 写成 \\alpha ),导致精确匹配失败进入 loose_escape 回退路径。该路径虽然能定位到正确的匹配位置,但直接使用 LLM 原始 newString(同样带有转义错误)写入文件,造成静默数据损坏——每次此类替换都会在文件中 引入错误的反斜杠数量。 解决方案 新增 ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/lessweb/deepcode-cli git https://github.com/lessweb/deepcode-cli.git
octolytics-dimension-user_id118287711
octolytics-dimension-user_loginlessweb
octolytics-dimension-repository_id1223512305
octolytics-dimension-repository_nwolessweb/deepcode-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1223512305
octolytics-dimension-repository_network_root_nwolessweb/deepcode-cli
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/lessweb/deepcode-cli/pull/136/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F136%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F136%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=lessweb%2Fdeepcode-cli
Reloadhttps://github.com/lessweb/deepcode-cli/pull/136/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/136/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/136/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
lessweb https://github.com/lessweb
deepcode-clihttps://github.com/lessweb/deepcode-cli
Notifications https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Fork 152 https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Star 1.7k https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Code https://github.com/lessweb/deepcode-cli
Issues 43 https://github.com/lessweb/deepcode-cli/issues
Pull requests 22 https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality 0 https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Code https://github.com/lessweb/deepcode-cli
Issues https://github.com/lessweb/deepcode-cli/issues
Pull requests https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
fym998https://github.com/fym998
lessweb:mainhttps://github.com/lessweb/deepcode-cli/tree/main
fym998:fix/loose-escape-newstring-correctionhttps://github.com/fym998/deepcode-cli/tree/fix/loose-escape-newstring-correction
Conversation 5 https://github.com/lessweb/deepcode-cli/pull/136
Commits 6 https://github.com/lessweb/deepcode-cli/pull/136/commits
Checks 9 https://github.com/lessweb/deepcode-cli/pull/136/checks
Files changed https://github.com/lessweb/deepcode-cli/pull/136/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
fix(edit): 修复 LLM 转义错误时 loose_escape 回退路径写入错误内容的问题 https://github.com/lessweb/deepcode-cli/pull/136/files#top
Show all changes 6 commits https://github.com/lessweb/deepcode-cli/pull/136/files
e3ea9a4 fix(edit): correct newString escaping in loose_escape fallback path fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/e3ea9a4b5c7535d3ff499ae56bd1127d1e714d52
5c7b300 test(edit): verify newString escaping correction in loose_escape fall… fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/5c7b30047d107036e59e84216e68c46afc08a25b
708ce67 fix(edit): handle zero-count loose escape correction fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/708ce675197c0205b2fad9433a97f29904fce52b
77a06df fix(edit): prefer deterministic loose escape correction fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/77a06df60dc7354d87d13c37ac07601e407868f0
93b4f63 fix(edit): return error instead of silently writing uncorrected newSt… fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/93b4f638e5b54985c039d7a956d2a8eae8530137
6fd4e2e refactor(edit): rename escape correction cursors fym998 May 30, 2026 https://github.com/lessweb/deepcode-cli/pull/136/commits/6fd4e2ebf31a0f88c6316b2a1ca7e76696c24af2
Clear filters https://github.com/lessweb/deepcode-cli/pull/136/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
tool-handlers.test.ts https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
edit-handler.ts https://github.com/lessweb/deepcode-cli/pull/136/files#diff-36f38f3211ee04026d4b0e66e2e7879a839f4b180c943aa1b2505deb17926aad
src/tests/tool-handlers.test.tshttps://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
View file https://github.com/lessweb/deepcode-cli/blob/6fd4e2ebf31a0f88c6316b2a1ca7e76696c24af2/src/tests/tool-handlers.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/136/{{ revealButtonHref }}
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
https://github.com/lessweb/deepcode-cli/pull/136/files#diff-9a2afa2cb4b4976515e3086fe5744647f96f2b248c3c3d2bff93807235f689c5
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/136/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.