Repository navigation
fix(windows): 修复长路径启动崩溃与文件搜索失败 - #4825
Merged
sailist merged 2 commits intoNov 11, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 4ade11c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
sailist
approved these changes
Nov 11, 2026
Merged
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 11, 2026
…pgrep cwd Port upstream MoonshotAI#4825. When the glob search root exceeds the Windows path limit, run ripgrep from a shorter parent directory and prefix the glob patterns with the relative path so matches and ordering are unchanged. The hostProcessService pipe-error containment from the same upstream PR is already equivalent under the Bun spawn translation.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
需求或缺陷
在 Windows 上,即使工作目录真实存在,较长的 cwd 仍可能导致 Core 子进程启动失败,随后触发未处理的
read ENOTCONN,使整个宿主退出。本次修复让启动失败正常返回给调用方,并让 Glob 能够搜索长目录。关联 issue:#4749。以下复现使用隔离的合成文件,验证范围覆盖真实 Core 工具类,不包含原应用的完整生命周期。该 issue 目前尚无维护者的
/approve评论。缺陷复现步骤
fixture.txt,以及仅包含print("CWD_PROBE_OK")的fixture.py。HostProcessService执行cmd.exe /d /c echo CWD_PROBE_OK;再通过真实 Bash 工具执行PYTHONDONTWRITEBYTECODE=1 python -B "fixture.py" verify。fixture.*。每次长路径调用后,在同一个运行时进程中继续执行短路径探针。改前和改后使用同一套 harness 与原始 fixture 目录。harness 调用真实 Core 工具类,仅为环境、上下文等依赖提供最小接线;验证覆盖到工具层,不代表完整 CLI 或桌面应用会话验证。主实验传入的路径均不带扩展长度前缀。
spawn ENOENT后触发未处理的read ENOTCONN,宿主退出码为 1SpawnFailed,保留原始 ChildProcess 错误为 cause;同一 PID 的下一条短 cwd 探针成功spawn ENOENT后触发未处理的read ENOTCONN,宿主退出码为 1read ENOTCONN导致宿主退出码为 1两次构建均基于
f26481d2bf20fe35fdce4ea6546953fc0552e6b4。实测环境:Windows 1110.0.26300、Node24.15.0、Core0.6.0、CLI 源码包2.5.3、pnpm10.33.0、Git Bash5.2.37、Git for Windows2.47.1.windows.2、ripgrep15.0.0、Python3.10.11。系统长路径支持原本已启用,本次没有修改该设置。根因
HostProcessService等待 ChildProcess 启动后,才构建现有流封装。Windows 拒绝长 cwd 时,ChildProcess 会发出启动错误,其尚未连接的管道也可能在流处理者建立前发出错误。仅捕获 ChildProcess 错误,仍会留下未处理的管道错误。Glob 原本使用
cwd=searchRoot启动 rg。一个目录可以被 rg 作为路径参数读取,却不能作为 Win32 进程的 cwd。直接改用其他 cwd,又会改变 anchored 模式和包含路径的--glob模式的匹配基准。管道错误处理修复了宿主崩溃;Glob 的改动绕过 Windows cwd 长度限制,并不使原生进程支持任意长度的 cwd。
代码改动
启动阶段监听只属于单次启动尝试,在成功移交或管道关闭后移除。同步 spawn 异常继续使用现有
SpawnFailed转换。Glob 的 rg 可执行文件探测也处理了 workspace cwd 本身过长的情况。搜索范围仍限于指定根目录,内部模式转换保留普通、anchored、含路径、否定、brace 等匹配语义,并转义根路径中的 glob 元字符。现有 rg 查找与回退、EAGAIN 重试、ignore 参数、VCS 排除、敏感文件过滤、排序、分页和返回格式继续沿用原实现。普通短目录仍使用原 cwd 和
.搜索参数。行为变化与受影响用户
第一行由
hostProcessService.test.ts覆盖:原始 cause 身份、三个管道的早期与后续错误、失败清理,以及成功后的监听移交。Glob 相关行为由tools/glob.test.ts覆盖:长搜索根、长 workspace 根、anchored 模式、ignore、输出和现有短根集成场景。另外将一处现有外部根测试的断言统一为生产输出使用的/分隔符,使其能在 Windows 上运行;未为此改变生产输出。验证结果:两份聚焦测试 79 通过/1 跳过,包类型检查和
git diff --check通过。独立改前/改后 harness 的 43 组匹配、ignore、输出对照全部通过,覆盖普通及 anchored 模式、否定、brace、递归、目录模式、两种include_ignored值、嵌套 ignore、敏感文件过滤、排序、外部根输出,以及根路径包含 glob 元字符的情况。完整
pnpm run lint已通过(0 errors,现有 warnings 不阻断),pnpm run sherif通过。测试中的进程清理调用均等待dispose()完成。lint:imports在未改动文件中报告 4 条诊断。对同一基线导出的未修改源码运行检查,得到完全相同的诊断。本轮未运行完整应用生命周期及无关包的测试。验证命令与基线已有的导入诊断
基线已有诊断位于
agent/fullCompaction/fullCompactionService.ts、agent/task/completionRestore.ts、agent/task/taskOutput.ts和human/agent/origin.ts。检查清单
/approve(已关联 [Bug] Kimi Work 3.2.24: synchronous ENOTCONN escapes HostProcessService.spawn and terminates Daimon #4749,尚未获得批准)。gen-changesets技能,并添加 CLI patch 发布说明。