Skip to content

feat(cosh-ng): add WSL2 preview launcher from Git Bash - #3143

Open
zhoukailong wants to merge 1 commit into
agentic-os-org:mainfrom
zhoukailong:agent/code-developer/01a07f3f
Open

zhoukailong wants to merge 1 commit into
agentic-os-org:mainfrom
zhoukailong:agent/code-developer/01a07f3f

Conversation

@zhoukailong

Copy link
Copy Markdown
Collaborator

Why

Windows users want to try cosh-ng, but a native Windows port (terminal,
process, local IPC differences) is too costly to commit to before demand is
validated. This adds a scoped preview path: a lightweight launcher run from
Git Bash enters WSL2 via wsl.exe and starts the cosh-shell already
installed in a Linux distribution, in the directory matching the current
Windows working directory.

What changed

  • src/cosh-ng/scripts/cosh-wsl (new): preview launcher. Preflights
    wsl.exe, resolves the Windows cwd with the MSYS2 pwd -W extension
    (fails explicitly outside Git Bash), prints the four preview status
    declarations plus the out-of-scope notice on every start, forwards the
    path as a positional parameter under MSYS2_ARG_CONV_EXCL='*', and
    reports actionable errors for wslpath failure, an inaccessible directory,
    and a missing cosh-shell. COSH_WSL_DISTRO selects the distribution
    (default Ubuntu).
  • src/cosh-ng/tests/test-cosh-wsl.sh (new): 12 stub-verifiable cases on
    Linux (distro default/override, arg-conversion guard, byte-exact tricky
    paths without injection, cwd mapping, exit-code propagation, all failure
    branches, explicit pwd -W failure).
  • src/cosh-ng/scripts/run-test-gates.sh: registers run_wsl_launcher in
    the fast and all gates (shellcheck-missing handling mirrors the
    existing raw/rpm packaging gates).
  • Bilingual docs: new wsl-preview.md pages under
    docs/user-guide/{en,zh}/user-entrypoint/cosh-ng/, linked from the
    user-guide "Start here" lists and summarized in the cosh-ng READMEs.

Related issue

Refs #2770 (community preview; the issue stays open pending real
Windows/Git Bash/WSL2 acceptance — do not close on merge)

User / Agent impact

New opt-in preview entry point for Windows users. On every start the
launcher prints: cosh-ng actually runs on Linux inside WSL2; Git Bash is
only the Windows-side entry point; /mnt/c and other mounts may have
performance and permission differences; configuration and credentials stay
in the WSL user environment; pkg, svc, checkpoint, and Gateway are not
part of this preview. No existing command, exit code, or output changes.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed
  • Migration or rollback guidance is needed

Low risk: additive script + tests + docs only. component.toml platform
declarations unchanged; no new dependencies; the launcher is not part of
any packaging manifest.

Validation

  • bash tests/test-cosh-wsl.sh: 12/12 PASS, exit 0 (Linux stub level —
    stub wsl.exe/wslpath/cosh-shell; this is not real Windows/WSL2
    acceptance).
  • bash -n on the launcher, test, and gate script: exit 0.
  • node website/scripts/validate-locales.mjs: PASS (en/zh parity).
  • NOT CHECKED here (left to CI): shellcheck (not installed on the dev
    node), website/scripts/check-links.mjs (needs the docusaurus build).
  • PRE-EXISTING environment blocker (present at base, untouched by this
    change, follow-up needed): the dev node's Python 3.8 breaks
    packaging/raw/verify-release.py (import tomllib) and
    scripts/check_test_necessity.py (str.removesuffix), so
    tests/test-package-raw.sh cannot complete on that node.
  • Manual acceptance still required on real Windows + Git Bash + WSL2
    (NOT VERIFIED): start/exit of cosh-shell, real cwd mapping between the
    Windows workspace and the WSL filesystem, Ctrl+C/Ctrl+D, window resize,
    CJK input and paste, Bash command boundaries, OSC markers, approval
    interaction, authentication and session recovery, common file tools,
    real /mnt/c performance/permissions, and prompt quality for real
    wsl.exe errors (e.g. distribution not installed).

Documentation and rollback

Docs added bilingually (wsl-preview.md en/zh) and summarized in
src/cosh-ng/README.md / README_zh.md. Rollback: revert this commit;
the launcher, its tests, its gate registration, and the docs are fully
self-contained.

Add scripts/cosh-wsl, a community preview entry point that lets Git Bash
users on Windows start cosh-shell inside WSL2 in the directory matching
their Windows working directory. This is a preview path, not a native
Windows target: platform declarations are unchanged, and pkg, svc,
checkpoint, and Gateway stay out of the preview scope.

The launcher checks for wsl.exe, resolves the Windows cwd with the MSYS2
pwd -W extension (failing explicitly outside Git Bash), prints the four
preview status declarations on every start, and forwards the path as a
positional parameter under MSYS2_ARG_CONV_EXCL so quoting and injection
are impossible. Inside WSL it reports actionable errors for wslpath
conversion failure, an inaccessible directory, and a missing cosh-shell.

tests/test-cosh-wsl.sh covers twelve stub-verifiable cases on Linux
(distro default and override, argument-conversion guard, byte-exact
tricky paths, cwd mapping, exit-code propagation, and all failure
branches) and is registered in the fast and all test gates. Real
Windows/Git Bash/WSL2 interaction remains NOT VERIFIED and is listed
for manual acceptance.

Refs agentic-os-org#2770

Assisted-by: Codex:0.152.1
Signed-off-by: zhoukailong <324835893+zhoukailong@users.noreply.github.com>
Co-authored-by: multica-agent <github@multica.ai>
@CLAassistant

CLAassistant commented Sep 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added component:cosh-ng src/cosh-ng scope:documentation ./docs/|./*.md|./NOTICE labels Sep 8, 2026
@zkl123
zkl123 marked this pull request as ready for review September 11, 2026 07:38

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

ℹ️ 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".

echo "Error: directory is not accessible inside WSL: $linux_cwd (converted from $windows_cwd)" >&2
exit 1
fi
if ! command -v cosh-shell >/dev/null 2>&1; then

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 Resolve the packaged cosh entry point

For users who install cosh-ng through the documented ANOLISA/raw or RPM paths, cosh-shell is not exposed on PATH: the component manifest installs it under libexec/anolisa/cosh-ng, while only cosh is installed in bindir (the RPM likewise exposes /usr/bin/cosh). Consequently this check exits 127 for a normal installation and the new WSL preview cannot start. The tests miss the failure because their stub directory deliberately places a cosh-shell executable on PATH.

Useful? React with 👍 / 👎.

@zhoukailong

Copy link
Copy Markdown
Collaborator Author

代码评审报告 — PR #3143

评审者: reviewer (automated)
评审时间: 2026-09-11 15:30 CST
变更规模: +508 / −0,9 个文件(3 新增脚本/测试/文档,6 修改)


五维评审结论

维度 结论
方案合理性 ✅ 通过 — cosh-wsl 定位清晰,落位 scripts/ 不侵入任何 crate,MSYS2_ARG_CONV_EXCL='*' 防路径转换正确
功能完备性 ✅ 通过 — 12 个 stub 测试覆盖 distro default/override、ARG_CONV_EXCL guard、tricky 路径字节精确传递、cwd 映射、exit code 传播、所有 failure 分支、pwd -W 缺失
文档完整性 ✅ 通过 — 双语 wsl-preview.md 完整,user-guide README 和 cosh-ng README 双语均已更新入口链接
安全 ✅ 通过 — MSYS2_ARG_CONV_EXCL 阻止路径改写(case 3 验证),Windows 路径作为 positional parameter 不经过 eval(case 4 验证),内层脚本无 eval、无 unquoted expansion
代码质量 ✅ 通过 — 错误信息 actionable,注释解释 why,测试框架 stub 模式设计合理

Findings

未发现 P0/P1/P2 问题。

P3 — 剩余风险(非阻塞)

  1. 真实 Windows/WSL2 未验证:PR body 已充分披露未验证项(Ctrl+C/D、窗口 resize、CJK 输入、OSC markers、authentication session recovery 等),建议后续完成 manual acceptance checklist。
  2. shellcheck 未在 dev 节点执行:gate 中 run_wsl_launcher 在 shellcheck 缺失时 return 1(fail-closed),CI 环境应有 shellcheck,不构成遗漏。
  3. launcher 未注册到独立 full gate:当前 run-test-gates.sh 仅有 fast/all/core/integration 四个 case,full 不存在,故无遗漏。

验证与覆盖声明

项目 状态
方案合理性 ✅ 已覆盖(静态)
功能完备性 ✅ 已覆盖(静态,测试设计分析)
文档完整性 ✅ 已覆盖(静态,双语对照)
安全性 ✅ 已覆盖(静态,注入变体分析)
代码质量 ✅ 已覆盖(静态)
bash tests/test-cosh-wsl.sh ❌ 未执行(需 Linux 环境)
shellcheck ❌ 未执行(需 Linux 环境)

声明:本次为纯静态评审,未执行 shell 测试或 shellcheck。测试设计经静态分析认为覆盖充分且有区分度。


总结

未发现阻塞问题。 这是一个干净的 additive PR,不触碰任何现有 crate、IPC 契约或平台声明。安全防御点设计正确且有测试覆盖。建议合并,后续完成真实 Windows/Git Bash/WSL2 环境的 manual acceptance。

@zhoukailong

Copy link
Copy Markdown
Collaborator Author

🔄 Incremental Code Review — PR #3143

评审者: reviewer (automated)
评审时间: 2026-09-11 23:50 CST
评审类型: 增量评审(代码未变更,新发现来自社区 bot 评论的 P1 finding 验证)


触发原因

自上次评审(2026-09-11 15:30 CST)后,chatgpt-codex-connector[bot] 在 scripts/cosh-wsl:58 提出 P1 finding:标准安装下 cosh-shell 不在 PATH 上。本次评审验证了该 finding 的正确性。


P1 — cosh-shell 不在标准安装 PATH 上,launcher 对正常安装用户必定失败

file:line: src/cosh-ng/scripts/cosh-wsl:58

可复现场景:

  1. 用户通过 RPM(dnf install cosh-ng)或 raw 包安装 cosh-ng
  2. 从 Git Bash 运行 cosh-wsl
  3. launcher 进入 WSL 后执行 command -v cosh-shell
  4. 返回 127,打印 "cosh-shell was not found on PATH"

问题本质:

经验证,所有标准安装路径(RPM spec、raw/deb package、component.toml)都将 cosh-shell 安装到 libexec/anolisa/cosh-ng/cosh-shell(不在 PATH 上)。只有 cosh 被安装到 bindir(RPM 中是 symlink,raw 中是 wrapper script)。

这意味着:

  • RPM 安装:/usr/bin/cosh → symlink → /usr/libexec/anolisa/cosh-ng/cosh-shell
  • Raw 安装:/usr/bin/cosh → wrapper script → exec -a "$0" "$runtime_dir/cosh-shell"

command -v cosh-shell 在两种安装方式下都无法找到目标,launcher 对任何通过标准方式安装的用户都不可用。

测试未覆盖此场景,因为 stub 目录直接将 cosh-shell 放在了 PATH 上。

最小修复方向:

launcher 应使用 cosh 而非 cosh-shell(cosh 是标准安装的 PATH 入口)。cosh 的 wrapper/symlink 会正确 delegate 到 cosh-shell 并保留 argv[0],不影响 TUI-vs-passthrough 判断。具体修改点:

  • scripts/cosh-wsl:58: command -v cosh-shell → command -v cosh
  • scripts/cosh-wsl:62: exec cosh-shell → exec cosh
  • scripts/cosh-wsl:59-60: 错误信息中的 cosh-shell → cosh
  • tests/test-cosh-wsl.sh: stub 应创建 cosh 而非 cosh-shell(或两者都创建以测试 fallback)
  • 文档中 cosh-shell 的引用也应对齐

验证与覆盖声明

项目 状态
cosh-shell install path 验证 ✅ 已验证(RPM spec、raw package.sh、component.toml 三方交叉确认)
测试覆盖差距确认 ✅ 已确认(stub 直接放置 cosh-shell 在 PATH,绕过了真实安装场景)
代码 diff 变更 无新 commit,代码未变

声明:本次为静态验证评审,聚焦 P1 finding 的确认。


总结

上次评审结论中「未发现 P0/P1/P2 问题」需修正:标准安装下 launcher 不可用是一个 P1 功能缺陷。建议在合并前修复 launcher 中的二进制引用(cosh-shell → cosh),并更新测试 stub 以反映真实安装布局。修复后其余维度评审结论不变。

This branch has not been deployed

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

Labels

component:cosh-ng src/cosh-ng scope:documentation ./docs/|./*.md|./NOTICE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants