Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.sh text eol=lf
*.ps1 text eol=lf
*.py text eol=lf
*.mjs text eol=lf
46 changes: 46 additions & 0 deletions .github/workflows/codewhale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Codewhale installer
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: '22'
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1
with:
python-version: '3.x'
- name: Offline contracts
run: node --test test-codewhale.mjs
- name: Actual menu terminal routing
if: runner.os != 'Windows'
run: python3 test-codewhale-menu.py
- name: PowerShell entrypoint contracts
shell: pwsh
run: ./test-codewhale.ps1
- name: Windows PowerShell 5.1 contracts
if: runner.os == 'Windows'
shell: powershell
run: .\test-codewhale.ps1
- name: Real install, without OAuth or inference
shell: pwsh
run: |
$env:npm_config_prefix = Join-Path $env:RUNNER_TEMP 'codewhale-npm'
$env:LMM_CODEWHALE_HOME = Join-Path $env:RUNNER_TEMP 'codewhale-auth-unused'
Remove-Item Env:LMM_CODEWHALE_BIN -ErrorAction SilentlyContinue
node codewhale.mjs install
if ($LASTEXITCODE) { throw 'Codewhale installation/verification failed' }
node codewhale.mjs doctor
if ($LASTEXITCODE) { throw 'Native/adapter verification failed' }
if (Test-Path $env:LMM_CODEWHALE_HOME) { throw 'Install unexpectedly created OAuth state' }
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
shell: powershell
run: |
$env:PI_CODING_AGENT_DIR="$env:RUNNER_TEMP\pi-profile"
# Expose only this job's chosen install path; no persistent user PATH changes.
$env:PATH="$env:PI_CODING_AGENT_DIR\bin;$env:PATH"
$env:DSH_HOME="$env:RUNNER_TEMP\dsh-profile"
$env:CODEX_HOME="$env:RUNNER_TEMP\codex-profile"
$env:CODEX_INSTALL_DIR="$env:RUNNER_TEMP\codex-bin"
Expand All @@ -67,7 +69,7 @@ jobs:
& powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ".\$tool.ps1"
if ($LASTEXITCODE) { throw "$tool install failed: $LASTEXITCODE" }
}
foreach ($command in @('pi.cmd','dsh.cmd',"$env:CODEX_INSTALL_DIR\codex.exe","$HOME\.local\bin\claude.exe","$HOME\.local\bin\lmm.exe")) {
foreach ($command in @("$env:PI_CODING_AGENT_DIR\bin\pi.cmd",'dsh.cmd',"$env:CODEX_INSTALL_DIR\codex.exe","$HOME\.local\bin\claude.exe","$HOME\.local\bin\lmm.exe")) {
& $command --version
if ($LASTEXITCODE) { throw "$command failed: $LASTEXITCODE" }
}
Expand Down
70 changes: 70 additions & 0 deletions CODEWHALE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Codewhale 一键安装和 LMM 配置

需要 Node.js 22+ 和 npm。Bash 入口单独下载时还需要 curl。脚本不代装 Node,不改 npm registry,不使用 sudo 或 `--force`。安装使用官方的 `npm install --global codewhale@latest`;二进制选择和校验仍由官方 npm 安装器负责。LMM 适配器安装固定 Git 提交 `8c78be0f936fb8f508badabc0195cdb21442a75d`,禁用其 npm 生命周期脚本;不依赖尚未发布的 npm 包。

## 安装并配置

Linux、macOS,或已准备好原生 Node/npm 的 Termux:

```sh
curl -fsSLo codewhale.sh https://raw.githubusercontent.com/TokenNotIncluded/lmm-scripts/main/codewhale.sh
bash codewhale.sh
```

Windows PowerShell:

```powershell
Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/TokenNotIncluded/lmm-scripts/main/codewhale.ps1 -OutFile codewhale.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File .\codewhale.ps1
```

默认执行 `setup`:安装、检查原生程序、通过浏览器 OAuth 登录,再询问是否选择模型启动。已有授权会保留,不会重新登录覆盖。OAuth 授权仍必须由本人在网页确认;脚本不绕过同意页。拒绝或失败不会被报告为成功。

**服务端必须先合并并部署 api.lmm.best PR #440 中的 `lmm-codewhale` 注册。** 安装成功不是生产登录成功,更不代表已完成计费验收。

## 菜单和独立命令

总菜单新增 `codewhale`:普通环境第 8 项,Termux 第 6 项,原有工具编号不变。进入后可选择安装并配置、仅安装/更新、登录、选模型启动、模型列表、登录状态、余额、用量、撤销授权或检查安装。菜单中的退出登录有二次确认。

```sh
bash codewhale.sh menu
bash codewhale.sh install # 仅安装,适合自动化;不登录
bash codewhale.sh login
bash codewhale.sh login --no-browser
bash codewhale.sh models
bash codewhale.sh run # 多模型时按编号选择;0 取消
bash codewhale.sh run --model '<完整目录 ID>' -- exec '检查项目测试'
bash codewhale.sh status
bash codewhale.sh balance
bash codewhale.sh usage
bash codewhale.sh logout # 撤销失败时由适配器保留凭据
bash codewhale.sh doctor # 原生程序 --version/--help + 适配器 --help
```

PowerShell 将 `bash codewhale.sh` 换为 `.\codewhale.ps1`。克隆仓库后也可直接运行 `node codewhale.mjs menu`,两个入口共用这一份实现。

非交互环境不能运行 `setup`/`menu`,请显式使用 `install`。非交互启动有多个模型时必须传 `--model`,不猜测模型和分组。`--no-browser` 只是手动打开授权 URL,回环回调仍需浏览器能够访问当前机器,不是 device-code 或 SSH 登录方案。

## 配置和平台边界

脚本只调用适配器,不另外复制 access/refresh token,不覆盖 Codewhale 的 TOML、shell 配置或系统 PATH。已有的 `LMM_ISSUER`、`LMM_CODEWHALE_HOME` 仍由适配器使用。正常启动显式使用官方 npm 解析到的原生二进制,而不是 Windows 的 `codewhale.cmd`;也可通过 `LMM_CODEWHALE_BIN` 指定已有原生程序的绝对路径。

`codewhale-lmm run` 在每次运行时建立临时 provider 配置,结束后清理。它不会合并用户原 TOML 中的自定义运行参数。这是伴随 CLI 接入,不是原生 `/login LMM` 插件。目前只支持目录声明的 Chat Completions 模型。

单独下载的 Bash/PowerShell 入口使用固定提交和 SHA-256 校验共用脚本;下载失败、内容不匹配或子进程失败都会停止后续步骤。克隆源码时使用同目录文件,便于维护;这不是对可修改本地目录的完整性保护。

Termux 先准备 `pkg install nodejs npm`,Codewhale Android 资产和设备支持仍属预览,不把 Linux ARM64 程序冒充 Android 程序。Windows 适配器尚无独立 ACL 加固,不适合共享 Windows 账号。现有系统/包管理器安装发生文件冲突时应先核对,不用强制覆盖绕过。

## 验证

```sh
node --test test-codewhale.mjs
python3 test-codewhale-menu.py
pwsh -NoProfile -File test-codewhale.ps1
```

Node 测试使用模拟 npm、适配器和原生程序;菜单测试实际分配伪终端,覆盖本地/远程入口、原有编号、Termux 隐藏项和失败下载。PowerShell 测试覆盖语法、帮助、引号/反斜杠参数、退出码和校验拒绝。

新增 CI 在 Ubuntu、macOS、Windows 运行离线测试,并使用隔离的 npm prefix 做真实下载安装和无账号启动检查;另覆盖 Windows PowerShell 5.1。CI 结果以对应提交为准。以上都不代替生产账号 OAuth、真实推理和 Termux 真机验收。

接口依据:[官方安装文档](https://github.com/Hmbown/Codewhale/blob/1554ac11846bc3e1423b0ee66591eea2870f10b1/docs/INSTALL.md)、[官方 npm 原生程序解析](https://github.com/Hmbown/Codewhale/blob/1554ac11846bc3e1423b0ee66591eea2870f10b1/npm/codewhale/scripts/run.js)、[LMM 适配器](https://github.com/TokenNotIncluded/codewhale-lmm-provider)。
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ irm https://raw.githubusercontent.com/TokenNotIncluded/lmm-scripts/main/menu.ps1
| `cc-switch` | Linux 发行包/AUR,macOS Homebrew,Windows 官方 MSI | 桌面应用 |
| `clash-verge-rev` | Linux deb/rpm/AUR,macOS Homebrew,Windows WinGet | 桌面应用 |
| `lmm` | 0.1.0 预览版发行包;另支持 `--from-source` / `-FromSource` | 安装结束打印的完整路径 |
| `codewhale` | 官方 npm 安装 + 固定版本 LMM OAuth 适配器 | `bash codewhale.sh run` / `.\codewhale.ps1 run` |

Pi 的版本、Node、安装位置、权限和 Windows Git Bash 交给官方安装器。官方正常安装后,才从它选出的安装路径接着装 LMM 插件;取消或卸载不继续。现有 LMM alpha 只验证过 Pi 0.85.1,其他版本会明确跳过插件,不偷偷降级宿主。DSH 的宿主和插件继续固定已适配版本;其当前官方 README 使用 npx,没有现行的独立安装脚本,不能拿归档记录中的旧脚本替代。

不写供应商配置、不登录账号、不启用系统代理或 TUN。
原有安装器不写供应商配置、不登录账号、不启用系统代理或 TUN。Codewhale 默认 `setup` 会引导用户在浏览器确认 OAuth;`install` 只安装、不登录。两者都不覆盖原配置,见 [Codewhale 安装与配置](CODEWHALE.md)。

## Codewhale

菜单新增第 8 项 `codewhale`(Termux 为第 6 项),进入安装、登录、选模型启动、余额/用量和登出子菜单,原有工具编号不变。可直接运行 `bash codewhale.sh` 或 `.\codewhale.ps1` 完成安装和授权;非交互环境必须显式使用 `install`。需要服务端先部署 `lmm-codewhale` 注册,安装成功不代表生产登录已验证。

## 环境

Unix 入口需要 Bash、curl。Pi 的依赖提示由官方处理;DSH 另需 Node 22.19+(22.x)或 24+、npm。不修改 npm registry。
Unix 入口需要 Bash、curl。Pi 的依赖提示由官方处理;DSH 另需 Node 22.19+(22.x)或 24+、npm;Codewhale LMM 适配器需要 Node 22+ 和 npm。不修改 npm registry。

Codex/Claude 的 Linux、macOS、Windows 安装都用官方脚本,不要求 Node,也不限定 apt 发行版。先满足上游的系统和运行库要求。Alpine 的 Claude 需要 `bash curl libgcc libstdc++ ripgrep`,运行时使用 `USE_BUILTIN_RIPGREP=0 claude`。NixOS 请使用 Nix 包环境,不保证通用二进制可运行。

Expand All @@ -39,18 +44,18 @@ LMM 预览包仅提供 Linux x64(glibc 2.39+)、macOS arm64、Windows x64,

## Termux

Pi 先运行 `pkg install nodejs npm git` 准备 Android 原生依赖,再调用同一个官方安装器;没有 `TMPDIR` 时使用 `$PREFIX/tmp`。DSH 使用同一 npm 安装方式,Android 原生依赖尚未真机验证。
Pi 先运行 `pkg install nodejs npm git` 准备 Android 原生依赖,再调用同一个官方安装器;没有 `TMPDIR` 时使用 `$PREFIX/tmp`。DSH 使用同一 npm 安装方式,Android 原生依赖尚未真机验证。Codewhale 使用官方 npm 的 Android 资产选择,不回退为 Linux ARM64 二进制,仍属预览且未完成真机验收。

Codex/Claude 使用**已有的 PRoot Linux 环境**,不是 Android 原生二进制。先准备 `proot-distro` 和 Ubuntu guest,并在 guest 中安装 Bash、curl、CA 证书,再运行相应脚本。其他 guest 用 `LMM_DISTRO=名称 bash codex.sh`。安装后进入同一 guest 运行 `codex` / `claude`;不再生成转发启动器,不创建或重置 guest,不关闭沙箱。两个桌面工具不支持 Termux,菜单会隐藏它们。

## 从旧版切换

旧的 `--network`、`--root`、`--check`、`--update` 等自定义参数已移除;不要继续传入。Codex/Claude 只接受各自官方参数,DSH 可传 profile。旧版 `lmm-tools` 目录不会被删除;从 PATH 中移除旧的 `lmm-tools/bin`,避免旧启动器优先于新安装。配置和账号数据不迁移、不清空。

所有安装代码平铺在根目录;只有两个 Unix 桌面入口共用 `desktop.sh`。本地运行用同目录文件,单独下载运行时用固定 Git 提交获取共用脚本;菜单同样固定到完整的安装器提交。不维护生成器或哈希清单。
所有安装代码平铺在根目录;两个 Unix 桌面入口共用 `desktop.sh`,Codewhale 两个平台入口共用 `codewhale.mjs`。本地运行用同目录文件,单独下载运行时用固定 Git 提交获取共用脚本;Codewhale 额外校验 SHA-256。菜单同样固定到完整的安装器提交。不维护生成器或独立哈希清单。

## 依据与测试

2026-09-21 核查:[Pi 官网安装入口](https://pi.dev/)([Shell](https://pi.dev/install.sh) / [PowerShell](https://pi.dev/install.ps1))· [Codex](https://learn.chatgpt.com/docs/codex/cli) · [Claude Code](https://code.claude.com/docs/en/setup) · [Pi Termux](https://pi.dev/docs/latest/termux) · [DSH 当前 README](https://github.com/deepseek-ai/deepseek-harness/blob/master/README.md) · [DSH 插件](https://deepseek-harness.github.io/deepseek-harness/en/develop/basic/publish) · [CC Switch](https://github.com/farion1231/cc-switch#download--installation) · [Clash Verge Rev](https://www.clashverge.dev/install.html)。LMM 插件适配版本见 [Pi 插件](https://github.com/TokenNotIncluded/pi-lmm-provider) 和 [DSH 插件](https://github.com/TokenNotIncluded/dsh-lmm-provider)。
2026-09-21 核查:[Pi 官网安装入口](https://pi.dev/)([Shell](https://pi.dev/install.sh) / [PowerShell](https://pi.dev/install.ps1))· [Codex](https://learn.chatgpt.com/docs/codex/cli) · [Claude Code](https://code.claude.com/docs/en/setup) · [Pi Termux](https://pi.dev/docs/latest/termux) · [DSH 当前 README](https://github.com/deepseek-ai/deepseek-harness/blob/master/README.md) · [DSH 插件](https://deepseek-harness.github.io/deepseek-harness/en/develop/basic/publish) · [CC Switch](https://github.com/farion1231/cc-switch#download--installation) · [Clash Verge Rev](https://www.clashverge.dev/install.html)。LMM 插件适配版本见 [Pi 插件](https://github.com/TokenNotIncluded/pi-lmm-provider) 和 [DSH 插件](https://github.com/TokenNotIncluded/dsh-lmm-provider)。Codewhale 依据和平台限制见 [专用说明](CODEWHALE.md)。

本地检查:`python3 test.py`、`pwsh -NoProfile -File test.ps1`、`shellcheck *.sh`。CI 另做三平台 CLI 实装和 Debian/Alpine 实装;不把模拟测试当作桌面 GUI、Termux 真机、账号登录或代理功能实测。
本地检查:`python3 test.py`、`pwsh -NoProfile -File test.ps1`、`shellcheck *.sh`。Codewhale 另有 `node --test test-codewhale.mjs`、`python3 test-codewhale-menu.py`、`pwsh -NoProfile -File test-codewhale.ps1`。CI 另做三平台 CLI 实装和 Debian/Alpine 实装;不把模拟测试当作桌面 GUI、Termux 真机、账号登录或代理功能实测。
Loading
Loading