Skip to content

fix(kaos): resolve Git Bash POSIX paths for file tools on Windows#2200

Open
wszqkzqk wants to merge 1 commit into
MoonshotAI:mainfrom
wszqkzqk:fix/windows-git-bash-paths
Open

fix(kaos): resolve Git Bash POSIX paths for file tools on Windows#2200
wszqkzqk wants to merge 1 commit into
MoonshotAI:mainfrom
wszqkzqk:fix/windows-git-bash-paths

Conversation

@wszqkzqk

Copy link
Copy Markdown
Contributor

Add a shell path bridge that translates between win32 paths and the MSYS2/Git Bash path dialect. File tools resolve model-supplied paths through it before canonicalization and workspace checks: drive-letter forms translate lexically, root-relative paths resolve via cygpath -w with per-segment caching, and every failure mode falls back to the previous behavior.

Fixes #2199

Related Issue

Resolve #2199

Problem

See linked issue. On Windows + Git Bash, file tools resolve root-relative
POSIX paths (/tmp/..., /home/...) against the current drive root
instead of the shell's mount table: Read reports file-not-found for
files bash just created, and Write/Edit silently create files at
wrong locations such as C:\tmp\....

What changed

  • Added a shell path bridge (kaos, vendored into agent-core-v2 per the
    environmentProbe.ts pattern) and wired it into the file-tool path
    guard: drive-letter forms (/c/x, /cygdrive/c/x) translate lexically,
    root-relative paths resolve via cygpath -w (cached per first segment),
    so file tools interpret paths exactly as the shell does.
  • The guard still canonicalizes and enforces workspace policy on the
    translated path — translation cannot widen access.
  • Replaced the duplicated inline cwd conversion in both bash tools with
    the same bridge (toShellPath, identical semantics).
  • Every failure mode (missing cygpath.exe, execution failure) falls back
    to current behavior: no working case can regress. Command text is never
    rewritten; WSL is unaffected.
  • 145 new unit tests (lexical forms, cygpath success/failure/missing,
    guard integration).
Design notes and verification
  • cygpath is the authoritative source for the msys mount table (/tmp
    %TEMP%, /binusr/bin, user /etc/fstab entries); lexical rules
    or fstab parsing cannot cover these.
  • The bridge is memoized per environment object; a root segment costs at
    most one cygpath spawn per process, then hits the cache.
  • Deliberate scope: tool results keep native paths; user-facing surfaces
    (TUI, config files) are untouched.
  • Verification: lint / typecheck / full unit suites pass on macOS.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d10ae9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@d10ae9a
npx https://pkg.pr.new/@moonshot-ai/kimi-code@d10ae9a

commit: d10ae9a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4e5d5d074

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/kaos/src/shell-path-bridge.ts Outdated
Add a shell path bridge that translates between win32 paths and the
MSYS2/Git Bash path dialect. File tools resolve model-supplied paths
through it before canonicalization and workspace checks: drive-letter
forms translate lexically, root-relative paths resolve via cygpath -w
with per-segment caching, and every failure mode falls back to the
previous behavior.

Fixes MoonshotAI#2199
@wszqkzqk
wszqkzqk force-pushed the fix/windows-git-bash-paths branch from a4e5d5d to d10ae9a Compare July 26, 2026 07:22
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: file tools cannot resolve Git Bash POSIX paths (/tmp, /home) produced by shell commands

1 participant