cc-haha/docs/guide/global-usage.md
程序员阿江(Relakkes) 1cd90dc66a feat: let users opt out of bundled Computer Use
Computer Use is useful when explicitly needed, but exposing its MCP tools by default creates unnecessary desktop-control surface for users who want coding-only sessions. This adds a shared disable path for CLI flags, environment, and desktop settings while keeping preauthorized app state in one config file.

The same change also preserves Windows and WSL shell startup behavior by applying the MSYS argument-conversion guard only on WSL-bound launches.

Constraint: Computer Use MCP must not be exposed to the Coding Agent when disabled

Constraint: Desktop settings and CLI sessions need to read the same persisted Computer Use config

Rejected: Environment-only disable switch | desktop users need a persistent Settings control

Rejected: Remove Computer Use setup entirely | enabled sessions still need the existing built-in MCP path

Confidence: high

Scope-risk: moderate

Directive: Keep every new Computer Use entrypoint wired through loadStoredComputerUseConfig or the CLI disable flag before adding MCP tools

Tested: bun test src/utils/computerUse/gates.test.ts src/utils/computerUse/preauthorizedConfig.test.ts src/server/__tests__/computer-use-api.test.ts src/utils/shell/wslInterop.test.ts desktop/src/pages/ComputerUseSettings.test.tsx

Tested: bun run check:server; bun run check:desktop; bun run check:docs; bun run check:policy; bun run check:native; git diff --check

Tested: SKIP_INSTALL=1 ./desktop/scripts/build-macos-arm64.sh; codesign verify; hdiutil verify; built CLI Computer Use E2E exposure and disable checks

Not-tested: Full screenshot/control action after granting macOS Screen Recording permission on this machine
2026-05-06 11:40:49 +08:00

59 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 全局使用(任意目录启动)
如果你希望在任意项目目录直接运行 `claude-haha`,可以通过以下方式配置。配置完成后,`claude-haha` 会自动识别你当前所在的工作目录。
## macOS / Linux
`~/.bashrc``~/.zshrc` 中添加:
```bash
# 方式一:添加 PATH推荐
export PATH="$HOME/path/to/claude-code-haha/bin:$PATH"
# 方式二alias
alias claude-haha="$HOME/path/to/claude-code-haha/bin/claude-haha"
```
然后重新加载配置:
```bash
source ~/.bashrc # 或 source ~/.zshrc
```
## Windows (Git Bash)
`~/.bashrc` 中添加:
```bash
export PATH="$HOME/path/to/claude-code-haha/bin:$PATH"
```
### Windows + WSL 工具链
如果 `claude-haha` 运行在 Windows / Git Bash但 Node、Python、uv、bun 等工具主要安装在 WSL 里,可以显式通过 WSL 调用:
```bash
wsl -e bash -lc 'node --version && python3 --version'
```
cc-haha 会在检测到 `wsl` / `wsl.exe` 调用时自动设置 `MSYS2_ARG_CONV_EXCL=*`,避免 Git Bash 把 `/home/...` 这类 WSL 路径错误转换成 `C:/Program Files/Git/home/...`
如果你想让 Bash 工具默认进入 WSL可以在启动前设置
```bash
export CLAUDE_CODE_SHELL_PREFIX='wsl -e bash -lc'
```
Computer Use 仍然控制 Windows 桌面应用WSL 内的 CLI 工具不需要写入 `computer-use-config.json`。如果只使用 WSL 工具链、不需要桌面控制,建议使用 `--no-computer-use` 或在 Settings > Computer Use 中关闭它。
## 验证
配置完成后,进入任意项目目录测试:
```bash
cd ~/your-other-project
claude-haha
# 启动后询问「当前目录是什么?」,应显示 ~/your-other-project
```