Skip to content

chore(browser-runtime): make sync.mjs runnable on Windows - #1834

Merged
MagicLizi merged 7 commits into
makecindy:mainfrom
happy9zhang:fix/browser-runtime-sync-windows
Aug 6, 2026
Merged

chore(browser-runtime): make sync.mjs runnable on Windows#1834
MagicLizi merged 7 commits into
makecindy:mainfrom
happy9zhang:fix/browser-runtime-sync-windows

Conversation

@happy9zhang

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

scripts/browser-runtime/sync.mjs(vendored 同步脚本)此前在 Windows 上无法运行,导致维护者在 Windows 上无法重新生成 _generated/**

  1. msys GNU tar 路径与 glob 兼容:GNU tar 把 C: 盘符路径当成远程主机(host:path),且默认关闭通配符匹配。修复为把引号内的 Windows 路径转换为 /c/... 形式并给 tar 传 --wildcards
  2. path.sep 归一化path.join 在 win32 上输出反斜杠,导致 LOCAL_PATCHES 的 key(POSIX 正斜杠)永远匹配不上、leaf 的 src/ 前缀过滤把全部 leaf 文件过滤掉。修复为统一转成 POSIX 分隔符。

关键性质:不改变任何生成产物——重新生成后 contentHash 与既有 lock 完全一致(--check 通过),无 _generated / lock 变更。

变更类型

  • chore 工程维护

范围

UI 变化

不涉及:无 UI 代码路径。

怎么验证的

自动验证

node scripts/browser-runtime/sync.mjs --check
# [browser-runtime] lock is up to date (contentHash + counts match).
# contentHash=1bc2c6ddddf7(与既有 lock 完全一致,无产物变化)

Windows 10(git bash/msys)实测可完整跑通 sync.mjs(下载 tarball → 解压 → 应用 LOCAL_PATCHES → 生成 335 个文件)。

手工验证

不涉及。

未执行的验证

无。

风险

风险分类

  • 无已知风险(改动仅影响脚本在本机运行时的路径处理;产物逐字节不变,contentHash 已证明)

影响与回滚

  • 影响范围:仅 sync.mjs 在 Windows 本地运行;CI(Linux)路径行为不变(修复对 POSIX 路径为 no-op)
  • 回滚 / 降级方式:回退本 commit 即可

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

The vendoring sync script assumed POSIX-only paths:
- msys GNU tar treats `C:` drive letters as remote hosts and requires
  --wildcards for glob extraction; quoted Windows paths are converted to
  /c/... and tar gets --wildcards
- path.join emits '\' on win32, so LOCAL_PATCHES keys and the leaf 'src/'
  prefix filter never matched; normalize to POSIX separators

No generated artifacts change: contentHash stays identical to the lock.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
@happy9zhang
happy9zhang requested a review from a team as a code owner August 5, 2026 13:21
Copilot AI lite review requested due to automatic review settings August 5, 2026 13:21
happy9zhang added a commit to happy9zhang/cindy that referenced this pull request Aug 5, 2026
The sync.mjs Windows compatibility fixes moved to their own PR
(makecindy#1834); this PR keeps only the LOCAL_PATCHES allowedOrigins wiring.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 让 browser-runtime 同步脚本可在 Windows/Git Bash 环境运行,同时保持生成产物不变。

  • 通过与实际执行一致的 POSIX shell 检测 tar 实现,仅为 GNU tar 注入 --wildcards
  • 将 Windows 盘符路径转换为 MSYS 路径
  • 将 leaf 路径和本地补丁键统一为 POSIX 分隔符

Confidence Score: 5/5

当前代码已解决既有 tar 检测与执行环境不一致的问题,PR 看起来可以安全合并。

当前 HEAD 使用同一个解析出的 shell 探测并执行 tar,且仅在确认 GNU tar 时注入 --wildcards;没有剩余的阻塞性故障。

Important Files Changed

Filename Overview
scripts/browser-runtime/sync.mjs Windows 路径、shell 与 tar 兼容处理已补齐;既有 tar 相关评审问题在当前代码中均已修复。

Reviews (7): Last reviewed commit: "fix: use English for the sh-resolution e..." | Re-trigger Greptile

Comment thread scripts/browser-runtime/sync.mjs Outdated
Copilot AI previously approved these changes Aug 5, 2026

Copilot AI 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.

🟢 Ready to approve

变更范围集中在本地同步脚本的 Windows 兼容处理,且不涉及产物/运行时代码路径的行为变更。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

该 PR 修复 scripts/browser-runtime/sync.mjs 在 Windows(git bash/msys)下不可运行的问题,使维护者能够在 Windows 上重新生成并校验 packages/browser-control-runtime/src/_generated/**(且不改变生成产物)。

Changes:

  • shHide() 中对 msys 环境做兼容:将双引号内的 Windows 盘符路径转换为 /c/... 形式,并为 tar 注入 --wildcards
  • 统一路径分隔符为 POSIX(/),避免 win32 下 path.join/path.relative 产生的反斜杠导致 leaf 过滤与 LOCAL_PATCHES key 匹配失败。
File summaries
File Description
scripts/browser-runtime/sync.mjs 修复 Windows(msys) 下 tar/路径分隔符行为,保证同步脚本可在 Windows 正常运行且保持生成结果不变。
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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

ℹ️ 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 scripts/browser-runtime/sync.mjs Outdated
Greptile P1 + Codex P2: unconditionally injecting GNU tar's --wildcards
broke macOS maintainers' BSD/libarchive tar. The whole msys compatibility
path now runs only on win32; POSIX platforms keep the upstream command
byte-for-byte.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
@MagicLizi MagicLizi added the status:ci-running CI 还在跑(review-pr 自动维护,仅展示) label Aug 5, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@happy9zhang 👋 这个 PR 还有 2 条 review conversation 没 resolve(scripts/browser-runtime/sync.mjs),auto-review 因此暂时跳过、没法继续审查 / 合并。

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

@MagicLizi MagicLizi added status:ci-failed CI 失败(review-pr 自动维护,仅展示) status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) and removed status:ci-running CI 还在跑(review-pr 自动维护,仅展示) status:ci-failed CI 失败(review-pr 自动维护,仅展示) labels Aug 6, 2026
Copilot AI review requested due to automatic review settings August 6, 2026 05:22
Comment thread scripts/browser-runtime/sync.mjs Outdated
Copilot AI dismissed their stale review, a newer Copilot review was requested August 6, 2026 05:25
Copilot AI previously approved these changes Aug 6, 2026

Copilot AI 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.

🟢 Ready to approve

改动范围局限于本地同步脚本的 Windows 兼容处理,且 POSIX 平台路径保持不变的分支明确,未发现会影响现有生成逻辑与 lock 一致性的风险点。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@MagicLizi MagicLizi added status:ci-running CI 还在跑(review-pr 自动维护,仅展示) and removed status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) labels Aug 6, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@happy9zhang 👋 这个 PR 还有 2 条 review conversation 没 resolve(scripts/browser-runtime/sync.mjs),auto-review 因此暂时跳过、没法继续审查 / 合并。

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

On win32 the PATH may resolve to the system bsdtar/libarchive instead of
msys GNU tar; bsdtar treats unsupported options as fatal errors, so the
unconditional --wildcards injection aborted pnpm sync:browser-runtime.
Detect the tar implementation via `tar --version` (cached) and inject
--wildcards only for GNU tar; bsdtar matches extraction paths as
shell-style patterns natively, so no flag is needed there.

Greptile P1 round 1 (Windows bsdtar) / Codex P2 (BSD tar) — covers both.

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 6, 2026 10:22

Copilot AI 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.

🟡 Changes recommended

win32 下对 JSON.stringify(...) 产生的 quoted 路径直接做反斜杠替换会生成双斜杠 msys 路径(如 /c//Users//...),存在路径解析不一致风险,需要先解码 quoted string 再转换。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

scripts/browser-runtime/sync.mjs:92

  • win32 分支里对双引号参数做路径转换时直接处理捕获到的文本 p;但这里的路径参数目前都来自 JSON.stringify(...),其中每个 \ 在命令文本里会被转义成 \\。当前 toMsys(p) 会把这些转义反斜杠也当作路径分隔符替换成 /,从而生成类似 /c//Users//... 的双斜杠路径,存在被 msys/工具链按 UNC 或异常路径解析的风险。建议先把匹配到的 quoted string 用 JSON.parse 解码回原始路径,再做 toMsys,最后再 JSON.stringify 回去。
  const wildcards = isGnuTar() ? ' --wildcards' : '';
  const toMsys = (p) => p.replace(/^([A-Za-z]):[\\/]/, (_, d) => `/${d.toLowerCase()}/`).replace(/\\/g, '/');
  const posix = cmd
    .replace(/"((?:[A-Za-z]:)?[^"]*)"/g, (m, p) => JSON.stringify(toMsys(p)))
    .replace(/(^|\s)tar(\s)/g, `$1tar${wildcards}$2`);
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI dismissed their stale review, a newer Copilot review was requested August 6, 2026 11:16
Copilot AI previously approved these changes Aug 6, 2026

Copilot AI 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.

🟢 Ready to approve

变更范围小且均有 win32 条件分支/幂等归一化保护,未发现会影响 POSIX 行为或改变生成产物的逻辑问题。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@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: 8b5d523542

ℹ️ 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 scripts/browser-runtime/sync.mjs Outdated
@happy9zhang

Copy link
Copy Markdown
Contributor Author

回复 Copilot review(Changes recommended,2026-08-06T10:26:56Z):已修复(8b5d5235):toMsys 转换先折叠双反斜杠(JSON 转义场景)再转换盘符与分隔符,不再产出 /c//Users// 双斜杠 msys 路径。4 组路径用例(单反斜杠/正斜杠/JSON 转义双反斜杠/相对路径)验证通过。

@MagicLizi

Copy link
Copy Markdown
Contributor

@happy9zhang 👋 这个 PR 还有 1 条 review conversation 没 resolve(scripts/browser-runtime/sync.mjs),auto-review 因此暂时跳过、没法继续审查 / 合并。

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

@MagicLizi MagicLizi added status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) and removed status:ci-running CI 还在跑(review-pr 自动维护,仅展示) labels Aug 6, 2026
On win32 the PATH may only contain Git\cmd (not Git\bin), so a bare `sh`
would ENOENT and abort pnpm sync:browser-runtime. Resolve the Git-bundled
sh.exe via scripts/lib/posix-shell.mjs's resolvePosixShell (where.exe
derivation + Program Files / LOCALAPPDATA standard locations; non-win32
keeps PATH behavior). Fail with a clear install-Git message when no sh is
found (codex-connector P1, round 3).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 6, 2026 11:54
Comment thread scripts/browser-runtime/sync.mjs Outdated

Copilot AI 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.

🟡 Changes recommended

新增的错误提示文本与脚本其余输出语言不一致,需要调整以保持可维护性与一致的可读性。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

scripts/browser-runtime/sync.mjs:90

  • 这里新增的错误信息为中文,但该脚本其余错误/日志基本为英文;在跨区域维护(尤其是脚本类工具)场景下会造成体验不一致。建议改为英文(或至少中英双语)并明确这是 Windows 需要 Git for Windows 提供的 sh。
  if (!sh) {
    throw new Error(
      'sync: 找不到可用的 sh(未检测到 Git for Windows)。请安装 Git for Windows 后重试。',
    );
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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

ℹ️ 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 scripts/browser-runtime/sync.mjs
On win32 the Node process PATH may resolve `tar` to System32\bsdtar while
the Git sh resolves GNU tar — probing with execFileSync('tar') could then
report non-GNU and omit --wildcards, while the actual GNU tar in the sh
environment would treat quoted member patterns literally and abort the
extraction. isGnuTar() now probes `tar --version` through the resolved sh
(the same environment that runs the tar commands), keeping detection and
execution consistent (Greptile P1 + codex-connector P1, round 4).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 6, 2026 12:22
Copilot AI dismissed their stale review, a newer Copilot review was requested August 6, 2026 12:25
Copilot AI previously approved these changes Aug 6, 2026

Copilot AI 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.

🟢 Ready to approve

变更聚焦于 Windows 兼容性修复且未触及生成逻辑核心路径,发现的问题仅为错误信息语言一致性的小修正。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

scripts/browser-runtime/sync.mjs:99

  • 这里的错误信息是中文,而同文件内其他错误信息基本都是英文(例如 ghPreflight / parseGithubRepo 等),会导致脚本输出语言不一致、对非中文维护者不友好。建议改为英文或中英双语保持一致性。
    throw new Error(
      'sync: 找不到可用的 sh(未检测到 Git for Windows)。请安装 Git for Windows 后重试。',
    );
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@MagicLizi MagicLizi removed the status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) label Aug 6, 2026
The "could not locate a usable sh" error text was the only Chinese output
in the script; align it with the rest of the output language for
maintainability and readability (Copilot P1 round 5).

Signed-off-by: happy9zhang <happy9zhang@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 6, 2026 13:35
@happy9zhang

Copy link
Copy Markdown
Contributor Author

回复 Copilot review(Changes recommended,2026-08-06T11:57:53Z):已修复(6a440d41)——sh 定位失败的错误提示已改为英文("sync: could not locate a usable sh (Git for Windows not detected). Install Git for Windows and retry."),与脚本其余输出语言一致。

Copilot AI dismissed their stale review, a newer Copilot review was requested August 6, 2026 13:38

Copilot AI 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.

🟢 Ready to approve

变更范围小且聚焦于 Windows 兼容性处理,关键逻辑(POSIX 平台 no-op、GNU tar 探测与分隔符归一化)自洽,未发现会影响既有行为或产物一致性的明确问题。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@MagicLizi MagicLizi added status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) and removed status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) labels Aug 6, 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.

Light review passed. Windows compatibility changes are well-structured: path normalization, GNU/bsd tar detection, and sh resolution via the existing posix-shell helper. No security or correctness concerns.

@MagicLizi
MagicLizi merged commit 01c38b6 into makecindy:main Aug 6, 2026
8 checks passed
@MagicLizi

Copy link
Copy Markdown
Contributor

Making scripts cross-platform without breaking the POSIX path is trickier than it looks — the GNU vs bsd tar detection and the msys path rewriting are both done carefully here. Thanks for the solid fix! 🛠

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.

3 participants