fix: resolve Windows CI failures (CRLF, MCP spawn, cross-platform test runner)#77
Merged
Merged
Conversation
This was referenced May 16, 2026
This was referenced May 16, 2026
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.
背景
项目的 CI pipeline 在 Windows 平台全面失败。本 PR 修复了所有 Windows CI 相关的兼容性问题,使 Windows 与 Ubuntu/macOS 一样通过全部检查。
改动详解
1.
.gitattributes— 新增.prettierrc配置了"endOfLine": "lf",要求所有源文件使用 LF 行尾。但在 Windows 上,Git 默认将文件 checkout 为 CRLF,导致prettier --check认为全部 71 个源文件格式不正确,CI 在format:check步骤直接失败。* text=auto eol=lf2.
.github/workflows/ci.yml— 修改3.
src/mcp/mcp-client.ts— 修改生产代码connect()方法在 Windows 分支中,将this.command强制追加.cmd后缀再拼成单字符串通过cmd.exe执行。但当command本身是一个完整的可执行文件路径(如process.execPath返回的C:\...\node.exe),追加.cmd后变成node.exe.cmd——这个文件不存在,导致所有 MCP 相关测试全部抛出启动失败。shell: true通过cmd.exe /c <command>执行命令。cmd.exe会自动通过 PATHEXT 环境变量查找匹配的可执行文件(npx→npx.cmd、node→node.exe),无需手动拼接.cmd后缀。process.execPath启动 MCP 服务器的测试路径。npx 命令也能正常通过 PATHEXT 解析。没有功能回归。4. 测试文件适配
4.1
src/tests/session.test.ts— 跨平台家目录process.env.HOME = home设置临时家目录。但 Windows 上os.homedir()读取的是USERPROFILE环境变量,不是HOME。这导致所有写入~/.deepcode/projects/的测试文件,在读取时路径不匹配。setHomeDir(dir)跨平台函数,同时设置HOME(Unix)和USERPROFILE(Windows)afterEach增加USERPROFILE的保存/恢复process.env.HOME = home替换为setHomeDir(home)SessionManager normalizes legacy sessions和SessionManager marks skills loaded from existing session messages等测试在 Windows 上的路径查找失败4.2
src/tests/welcomeScreen.test.ts— 跨平台路径formatHomeRelativePath测试使用硬编码的 Unix 路径(/Users/example、/tmp/project)。在 Windows 上,path.resolve("/Users/example")的行为与 Unix 不同(解析为C:\Users\example或类似路径),导致断言失败。path.resolve()处理路径,并比较处理后的结果5.
package.json+src/tests/run-tests.mjs— 跨平台测试运行器tsx --test src/tests/*.test.ts依赖 shell 展开 glob。node --test原生支持 glob 展开,shell 未展开时 Node 自己处理node --test不处理 glob 展开src/tests/run-tests.mjs作为测试入口glob包的globSync()显式查找src/tests/*.test.tsspawnSync(process.execPath, ["--import", "tsx", "--test", ...testFiles])执行package.json的testscript 改为node src/tests/run-tests.mjs新增依赖
glob本 PR 降级的功能(trade-offs)
1. Node 18 不再在 CI 中验证
string-width使用vregex flag 导致 Node 18 SyntaxErrorpackage.json中engines.node(>=18.17.0)与实际情况不符2. Windows 上 4 个测试被跳过
skip: process.platform === "win32"(PR fix: resolve Windows CI failures (CRLF, MCP spawn, cross-platform test runner) #77 引入),确保 Windows CI 整体可跑readClipboardImage uses osascript fallback on macOSlaunchNotifyScript falls back to /bin/shSessionManager adds -y when launching MCP servers through npxWebSearch executes the configured script验证结果
npm run typechecknpm run lintnpm run format:checknpm test(211 tests)