Skip to content

feat(pi): 新增 Windows Git PATH 解析模块 - #2869

Open
nanaco666 wants to merge 12 commits into
makecindy:mainfrom
xindong:codex/issue-2590-windows-git-path
Open

feat(pi): 新增 Windows Git PATH 解析模块#2869
nanaco666 wants to merge 12 commits into
makecindy:mainfrom
xindong:codex/issue-2590-windows-git-path

Conversation

@nanaco666

@nanaco666 nanaco666 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

新增一个独立、可测试的 Windows Git/PATH 解析模块,为后续让 Cindy 管理的 Pi 在 Windows 上自动找到 Git Bash 提供基础能力。本次 review 修复保留 Windows 原生探测子进程在超时前已经输出的有效记录,避免断开的 UNC/映射盘候选抹掉同批次已成功探测的本地 Git 路径。

实现复用了 Git for Windows 的标准安装契约、Git 官方 git --exec-path 以及 oh-my-pi 已使用的 Windows PATH 处理方案,并按 Cindy 的 Pi harness 隔离结构收缩为纯探测模块。本 PR 只交付发现模块和测试,不接入 Pi 启动链路,因此不会提前改变线上行为。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:bug: windows 下使用 Pi,一直报错无 git bash #2590
  • 本 PR 包含:
    • 按 HKCU → HKLM 顺序读取 Git for Windows 安装信息,兼容仅为当前用户安装的场景;注册表值经 Windows PowerShell 的 .NET Registry Provider 读取,并用 UTF-16LE Base64 无损传输
    • 直接遍历传入的 Windows PATH 并校验 git.exe,避免 where.exe 原生代码页损坏,同时不搜索当前工作目录
    • 只接受 Git for Windows 标准 cmdbinusr/binmingw*/bin 布局
    • 对可直接执行的 shim 使用 Git 官方 git --exec-path 解析真实安装目录,不为 Scoop、Chocolatey 等包管理器写特判
    • .cmd 等不能安全直接执行的 wrapper 保持 fail-open,不启用 shell: true
    • MSYS 驱动器路径和安装根相对路径转换
    • Windows PATH 大小写不敏感去重
    • 对批量 PowerShell 探测设置 3 秒总超时;超时时保留 stdout 中已经完成的有效记录
    • 27 个跨平台纯函数单测,包含中文注册表/PATH、相对路径隔离、有界文件探测快照,以及本地 Git 与不可达 UNC/映射盘混合候选的超时回归
    • 按仓库既有生成机制补充固定 oh-my-pi commit 的 MIT 第三方声明与 SPDX SBOM
  • 明确不包含:
    • 不接入 Pi 的 spawn env 或 settings.json
    • 不继承用户 ~/.pi/agent/settings.json 或项目 Pi 配置
    • 不新增手动 Bash 路径设置、诊断 UI 或错误提示
    • 不修改 Desktop Terminal 的 shell resolver
  • 用户可见变化:无。本 PR 是后续 Pi Bash 接线 PR 的基础模块。
  • 是否存在 breaking change:无。

UI 变化

不涉及。

怎么验证的

自动验证

pnpm test:unit:related

结果:通过。

  • test:runner:407 项,399 通过、8 跳过、0 失败
  • apps/desktop unit:通过
  • packages/lizi-mcps unit:通过
  • packages/maker-core unit:通过
  • packages/orca-workflow unit:通过

其他针对性验证:

  • pnpm --filter @cindy/maker-core run --if-present typecheck:退出码 0;该 package 当前未定义独立 typecheck script
  • pnpm --filter @cindy/maker-core exec vitest run src/agents/pi/windows-git-path.test.ts:1 个测试文件,27/27 通过
  • pnpm --filter @cindy/maker-core exec eslint src/agents/pi/windows-git-path.ts src/agents/pi/windows-git-path.test.ts:通过
  • git diff --check:通过

未执行的验证

  • 未做 macOS 实机验证:非 Windows 分支由单测确认保持原 PATH 且不执行 Windows 探测。
  • 未做 Pi 真二进制启动验证:本 PR 明确不接入 Pi 启动链路;实际 Windows Pi 启动验证留给后续接线 PR。

风险

  • 影响范围:仅 Windows Git/PATH 解析模块及测试;没有生产调用方,不改变现有 Pi、Desktop Terminal、远端会话或非 Windows 行为。
  • 探测协议使用 UTF-16LE Base64,保证 Unicode Windows 路径安全。
  • 文件元数据统一在系统 PowerShell 子进程内批量探测并设置 3 秒总超时;超时时保留已输出的有效记录,断开的 UNC/映射盘不会抹掉此前成功的探测结果,也不会让 Cindy 主进程执行无界 statSync;异常保持 fail-open。
  • 回滚方式:直接回退本 PR 即可;没有配置、数据或协议迁移。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s
  • 未提交凭证、令牌或授权文件
  • 已完成仓库要求的提交前测试门禁

@nanaco666
nanaco666 marked this pull request as ready for review August 17, 2026 06:40
@nanaco666
nanaco666 requested a review from a team as a code owner August 17, 2026 06:40
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

新增独立的 Windows Git/PATH 探测模块,为后续 Pi 启动链路接入提供基础能力。

  • 从注册表及 Windows PATH 收集 Git for Windows 候选,并验证标准安装布局
  • 使用有界 PowerShell 批量探测路径类型,超时时保留已完成的有效记录
  • 支持 MSYS 路径转换、大小写不敏感去重及跨平台纯函数测试
  • 补充 oh-my-pi 适配代码的第三方声明与 SPDX SBOM 数据

Confidence Score: 5/5

当前变更看起来可以安全合并。

未发现仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
packages/maker-core/src/agents/pi/windows-git-path.ts 新增隔离的 Windows Git/PATH 发现与转换模块;先前线程要求的非标准 shim 拒绝行为已由布局校验实现。
packages/maker-core/src/agents/pi/windows-git-path.test.ts 覆盖注册表解码、PATH 候选、标准布局、shim 拒绝、MSYS 转换及超时保留部分结果等行为。
scripts/generate-third-party-notices.mjs 将固定 commit 的 oh-my-pi 适配代码加入桌面第三方声明生成源。
scripts/tests/third-party-notices.test.mjs 增加桌面分发声明包含 oh-my-pi 版权信息的回归断言。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Windows PATH 与注册表] --> B[收集 Git 候选]
  B --> C[分离本地与网络路径]
  C --> D[PowerShell 有界路径探测]
  D --> E[验证标准 Git for Windows 布局]
  E --> F[转换 MSYS 路径并去重]
  F --> G[返回解析后的 PATH]
Loading

Reviews (12): Last reviewed commit: "fix(pi): 复用 Windows 路径探测快照" | Re-trigger Greptile

@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: 85f8f13c97

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Comment thread packages/maker-core/src/agents/pi/windows-git-path.ts
Comment thread packages/maker-core/src/agents/pi/windows-git-path.ts Outdated
@nanaco666 nanaco666 changed the title feat(pi): add Windows Git PATH resolution helpers feat(pi): 新增 Windows Git PATH 解析模块 Aug 17, 2026
@MagicLizi MagicLizi added touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) awaiting-discussion 等待维护者讨论(review-pr) labels Aug 17, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@nanaco666 👋 这个 PR 还有 3 条 review conversation 没 resolve(packages/maker-core/src/agents/pi/windows-git-path.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi

Copy link
Copy Markdown
Contributor

👋 这个 PR 触发了维护者确认门(product:feat 新增能力 + arch:核心路径 343 行)。已开讨论 issue:#2877

维护者直接在 PR 上点 Approve 即放行;需要修改就 Request Changes,作者改完后重新 Approve。确认前本 PR 不会被自动合并,自动审查仍会照常进行。

Signed-off-by: nanaco <823073145h@gmail.com>
Signed-off-by: nanaco <823073145h@gmail.com>
@nanaco666
nanaco666 force-pushed the codex/issue-2590-windows-git-path branch from 85f8f13 to 4c9d858 Compare August 17, 2026 10:41

@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: 4c9d8586ba

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nanaco <823073145h@gmail.com>

@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: 405546d34d

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nanaco <823073145h@gmail.com>

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

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@nanaco666 👋 这个 PR 还有 1 条 review conversation 没 resolve(packages/maker-core/src/agents/pi/windows-git-path.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Signed-off-by: nanaco <823073145h@gmail.com>

@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: 68bed6622c

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nanaco <823073145h@gmail.com>

@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: 1cae0031d6

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nanaco <823073145h@gmail.com>

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

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nana <823073145@qq.com>

@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: 83457d306f

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts
Comment thread packages/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nana <823073145@qq.com>

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

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nana <823073145@qq.com>

@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: 4cfdbc4cfe

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts Outdated
Signed-off-by: nana <823073145@qq.com>

@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: 716be85ea2

ℹ️ 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/maker-core/src/agents/pi/windows-git-path.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@nanaco666 👋 这个 PR 还有 1 条 review conversation 没 resolve(packages/maker-core/src/agents/pi/windows-git-path.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Signed-off-by: nana <823073145@qq.com>
@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 21, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1×1:PR 描述仍写会用 Git 官方 git --exec-path 解析 shim,但当前 head 已完全去掉对 PATH 里 git 的执行,只做目录布局检查。请把摘要和「本 PR 包含」那条改成与现实现一致(并顺手更新过时的 27 个单测数字)。代码本身的安全方向是对的,卡的是描述与 diff 不符。

@@ -0,0 +1,527 @@
import { execFileSync } from 'node:child_process';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1:当前模块没有任何 git --exec-path / 对 PATH 候选 git.exe 的执行;execFileSync 只打 powershell.exe。PR 描述(摘要 + 「对可直接执行的 shim 使用 Git 官方 git --exec-path」)还在描述已删除的旧设计。请改描述对齐现实现,避免后续接线 PR 或安全审查按错误模型理解。

@MagicLizi MagicLizi added the status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) label Aug 21, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@nanaco666 👋 这个 PR 还有 1 条 review conversation 没 resolve(packages/maker-core/src/agents/pi/windows-git-path.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants