Skip to content

fix: route bash apply_patch through dedicated tool and improve path/prompt handling#885

Open
Barryshen1 wants to merge 2 commits into
XiaomiMiMo:mainfrom
Barryshen1:fix/bash-apply-patch-routing
Open

fix: route bash apply_patch through dedicated tool and improve path/prompt handling#885
Barryshen1 wants to merge 2 commits into
XiaomiMiMo:mainfrom
Barryshen1:fix/bash-apply-patch-routing

Conversation

@Barryshen1

@Barryshen1 Barryshen1 commented Jun 16, 2026

Copy link
Copy Markdown

This PR adds three small reliability improvements:

  • Route bash apply_patch invocations through the dedicated tool — Models often run apply_patch <<'PATCH'... via the bash tool instead of calling apply_patch directly, which bypasses diff preview, write permissions, and LSP post-checks. MiMo-Code already had Patch.maybeParseApplyPatch() but it was never wired into BashTool. This PR adds maybeParseApplyPatchFromCommand() and delegates matching commands to ApplyPatchTool.

  • Fix Windows memory path parsing (windows环境memory.reconcile路径正则只认正斜杠,反斜杠全部匹配失败 #861)parsePath() and parseCcPath() used forward-slash-only regexes, causing memory reconcile to skip all files on Windows. Paths are now normalized before matching.

  • Normalize CRLF in CLI --prompt input — MiMo-Code already normalized line endings for TUI paste events, but not for --prompt / piped stdin, which could garble the first message on Windows.

Test plan

  • bun test test/memory/paths.test.ts — Windows backslash path cases
  • bun test test/patch/patch.test.tsmaybeParseApplyPatchFromCommand cases
  • bun test test/cli/prompt-text.test.ts — CRLF normalization unit tests
  • bun test test/cli/tui/thread.test.ts--prompt CRLF normalized before TUI start
  • bun test test/tool/bash.test.ts — bash apply_patch heredoc routes through ApplyPatchTool and requests edit permission
  • Pre-push turbo typecheck passes across all packages

Related issues

…rompt handling

Route bash apply_patch heredocs through ApplyPatchTool for approval and safety,
normalize Windows memory paths for reconcile, and strip CRLF from CLI prompts.
…ting

Extract normalizePromptText for unit testing, verify CLI --prompt normalization in the
TUI thread path, and assert bash apply_patch heredocs route through ApplyPatchTool.
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.

windows环境memory.reconcile路径正则只认正斜杠,反斜杠全部匹配失败

1 participant