Skip to content

fix(agent-core-v2): spawn Windows batch script commands through cmd.exe (#4791) - #4804

Merged
liruifengv merged 1 commit into
release/2026-11-10from
fix/win32-spawn-cmd-shim-release-2026-11-10
Nov 10, 2026
Merged

liruifengv merged 1 commit into
release/2026-11-10from
fix/win32-spawn-cmd-shim-release-2026-11-10

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Requirement or Bug

将已合并到 main 的 #4791 cherry-pick 到 release/2026-11-10:修复 Windows 上以 npx 等 .cmd/.bat 脚本命令声明的 stdio MCP 服务器无法启动的问题。

Bug Reproduction Steps

见 #4791。

Root Cause

见 #4791。

Code Changes

cherry-pick main 的 squash commit 4d44cc6ee(#4791),无额外代码改动:

  • HostProcessService 主路径改用 cross-spawn(Windows 批处理命令自动解析与 cmd.exe 包装);显式 shell: true 的命令保留原生 spawn,避免退出码被误分类;
  • MCP stdio 启动失败分类:进程级 ENOENT 同样归类为配置错误(避免无限重连),退出错误的等待加有界回退防止挂死;
  • 携带 changeset(@moonshot-ai/kimi-code patch)。

唯一冲突为 flake.nix 的 pnpmDeps fetcherVersion 与 hash:保留 release 分支的 fetcherVersion = 3,hash 待 Nix CI 给出本分支依赖集对应的值后更新。

Behavior Changes and Affected Users

与 #4791 一致,无额外行为变化。

Checklist

  • I have read the CONTRIBUTING document.
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…xe (#4791)

* fix(agent-core-v2): spawn Windows batch script commands through cmd.exe

* fix(agent-core-v2): harden Windows batch spawn escaping and resolution

* fix(agent-core-v2): preserve native .com precedence in Windows spawn resolution

* fix(agent-core-v2): reject line breaks and align env and cwd resolution in Windows batch spawn

* refactor(agent-core-v2): replace custom Windows batch spawn handling with cross-spawn

* chore: update lockfile for cross-spawn

* chore: update nix pnpmDeps hash for cross-spawn

* fix(agent-core-v2): classify process-level ENOENT during MCP startup as config error

* fix(agent-core-v2): await transport exit error before classifying MCP startup failure

* fix(agent-core-v2): keep native spawn for explicit-shell commands on Windows

* fix(agent-core-v2): bound the MCP transport exit-error wait
@changeset-bot

changeset-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a0858bf

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T11:19:34.589684Z a0858bf PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 10, 2026

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

commit: a0858bf

@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: a0858bfc54

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"ajv": "^8.18.0",
"ajv-formats": "^3.0.1",
"chokidar": "^4.0.3",
"cross-spawn": "^7.0.6",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the Nix pnpm dependency hash

Adding this direct dependency changes pnpm-lock.yaml, but flake.nix:155-159 still contains the parent commit's fixed-output pnpmDeps hash. Consequently, the nix build .#kimi-code step in .github/workflows/nix-build.yml:103-113 will fail with the hash-mismatch path handled at lines 121-136, blocking the Nix build until flake.nix is updated with the newly reported hash.

Useful? React with 👍 / 👎.

@liruifengv

Copy link
Copy Markdown
Collaborator Author

关于 Nix pnpmDeps hash 的评审意见,经核实不需要处理:

  1. 本 PR 不会触发 Nix 构建:.github/workflows/nix-build.yml 的触发条件是 pull_request.branches: [main] 和 push.branches: [main],以 release/2026-11-10 为 base 的 PR 以及 release 分支的 push 都不会运行 nix build,不存在因此失败的路径。
  2. 本 PR 相对 release base 并未修改 flake.nix:cherry-pick 冲突解决时保留了 release 分支原有的 fetcherVersion = 3 与原 hash,该文件在 release 分支上相对分叉点没有变化。因此 release 回合 main 的 sync PR 中,main 侧较新的 flake.nix(fetcherVersion 5 及 main 依赖集对应的 hash)会原样保留,不会被回退。

如果后续确有在 release 分支上运行 Nix 构建的需求,再按当时 CI 报告的 got hash 单独更新即可。

@liruifengv
liruifengv merged commit c50a55b into release/2026-11-10 Nov 10, 2026
15 checks passed
@liruifengv
liruifengv deleted the fix/win32-spawn-cmd-shim-release-2026-11-10 branch November 10, 2026 11:24
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
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