返回 CodeWhale
INSTALL.md
根目录 / docs / INSTALL.md
1 # Installing Codewhale
2
3 > 阅读简体中文版:[zh_hans/INSTALL.md](zh_hans/INSTALL.md)
4
5 Codewhale is an open-source coding agent that runs in your terminal. You give
6 it a task ("fix the failing test", "add a CLI flag"). It reads your repository,
7 edits files and runs commands. In the default **Accept Edits** posture it
8 applies file edits inside the repository immediately and shows you the diff,
9 and asks before each shell command, so commit or stash anything you care about
10 first. **Ask** (`Shift+Tab` round the dial, or `/config`) asks before every
11 edit as well. It works with many model
12 providers. **DeepSeek** is the default.
13
14 The command is `codewhale`. `codew` is a shorter alias for the same program.
15
16 The installation paths were first checked with **v0.10.0** (released 2026-09-22) on a
17 fresh **Ubuntu 24.04 x86_64** machine. The dated
18 [install receipts](https://github.com/codewhale-hq/Codewhale/blob/37ecdfcc49bc68a9b0d058b97c3946e62c34bd31/docs/install-report/v0.10.0-2026-09-23/RECEIPTS.md) record the commands and output checked at that time. Steps that
19 could not be run on that machine are marked **(untested on this VM: reason)**.
20 macOS, Windows and Android are out of scope, apart from a few notes. A second
21 pass re-ran the installer, manual-download, archive and npm paths, the no-key
22 checks and zsh completion on **macOS 26.1 (Apple silicon)**; see
23 [macOS notes](#macos-notes). Steps that need a model call were not re-run
24 there.
25
26 Install commands that use `latest` resolve to the latest **published** GitHub
27 Release or package. Between releases, `main` may already describe the next
28 version (for example a v0.10.5 source candidate before its tag). A
29 prebuilt candidate is available through the official installer only after its
30 tag, checksums and release assets exist. Contributors can build `main` now.
31
32 ## No account needed
33
34 Codewhale needs no account. Keys you save with `/provider` or
35 `codewhale auth set` stay on your machine; see
36 [API keys and providers](#8-api-keys-and-providers). New Codewhale accounts
37 are not open, so this guide does not cover account key storage.
38
39 ## Test and contribute to current source
40
41 `latest` selects the latest published release. To test unreleased repairs,
42 build canonical GitHub `main`, or CNB `main` after verifying its commit matches.
43 The source version number alone does not establish a published package.
44
45 ```bash
46 git clone --branch main https://github.com/codewhale-hq/CodeWhale.git
47 cd CodeWhale
48 cargo build --release --locked -p codewhale-cli
49 target/release/codewhale --version
50 ```
51
52 See the Cargo section for build prerequisites; use the repository's pinned Rust
53 1.100.0 (declared minimum 1.89). Windows uses `target/release/codewhale.exe`
54 and needs MSVC. A development build is separate from a signed release package.
55 For mainland-China downloads and source validation, see [CNB mirror](CNB_MIRROR.md).
56 The [Tencent Lighthouse bootstrap](../scripts/tencent-lighthouse/README.md) is
57 bilingual. An npm registry mirror serves the wrapper; native binary downloads
58 still need an available release asset source. If a Lighthouse or
59 `codewhale remote-setup` runtime service was installed with an earlier release,
60 reinstall its unit and rotate `CODEWHALE_RUNTIME_TOKEN`: the older units passed the
61 token on the command line, and upgrading the binary does not change them. The
62 Lighthouse README has the steps.
63
64 ---
65
66 ## 60-second quickstart (Linux or macOS)
67
68 ```bash
69 # 1. Install. Downloads two checksum-verified binaries into ~/.local/bin (no sudo).
70 curl -fsSL https://codewhale.net/install.sh | sh
71
72 # 2. The installer adds ~/.local/bin to your shell profile (it prints what it added and
73 # how to undo it; --no-modify-path skips that). Shells that are already open do not
74 # reread the profile, so use it in this one now, then check it.
75 export PATH="$HOME/.local/bin:$PATH"; hash -r
76 codewhale --version # -> codewhale 0.10.0 (1be1a703b975)
77
78 # 3. Give it a DeepSeek API key (from https://platform.deepseek.com/api_keys).
79 codewhale auth set --provider deepseek # prompts for the key; nothing is echoed
80 codewhale auth status --provider deepseek # "active source: secret store"
81
82 # 4. Run your first task inside a git repository.
83 cd ~/your-project
84 codewhale
85 ```
86
87 In the TUI, type something concrete:
88
89 ```text
90 create a Python file primes.py that prints the first 10 primes, run it, and show me the output
91 ```
92
93 Codewhale writes the file, shows you a diff, then asks **APPROVAL: bash
94 python3 primes.py – Do you want to proceed?** Press `y` to allow it once. It
95 runs the command and reports the output. Press `Ctrl-D` (with an empty input
96 box) to quit. It prints the command to resume the session later.
97
98 > **If nothing happens after you send your first message,** you have not
99 > connected a model. v0.10.2 shows `no model connected · run /provider` on its
100 > first screen and returns your first message to the composer. Type `/provider`,
101 > choose a provider or paste a Custom endpoint, then send it again. If messages say
102 > they were saved for later after you connect, quit with Ctrl+D and run `codewhale` again.
103
104 ---
105
106 ## Contents
107
108 1. [Before you start](#1-before-you-start)
109 2. [Install: recommended installer](#2-recommended-installer-curl--sh)
110 3. [Install: manual download from GitHub Releases](#3-manual-download-from-github-releases)
111 4. [Install: npm](#4-npm)
112 5. [Install: Cargo / build from source](#5-cargo-and-building-from-source)
113 6. [Install: Homebrew (Linux) and Nix](#6-homebrew-on-linux-and-nix)
114 7. [Updating and rolling back](#7-updating-and-rolling-back)
115 8. [API keys and providers](#8-api-keys-and-providers)
116 9. [Shell completions](#9-shell-completions)
117 10. [Running it: TUI, headless, resume](#10-running-it)
118 11. [Terminal notes (Ghostty and others)](#11-terminal-notes)
119 12. [Uninstalling and what Codewhale leaves behind](#12-uninstalling)
120 13. [Troubleshooting](#13-troubleshooting)
121 14. [Appendix: other platforms (not re-tested in this revision)](#appendix-other-platforms-not-re-tested-in-this-revision)
122
123 ---
124
125 ## 1. Before you start
126
127 | You need | Why |
128 |---|---|
129 | Linux x86_64 or arm64, or macOS | Prebuilt binaries exist for these. The Linux binaries are **static** (musl), so they have no glibc or libdbus dependency and run on any distro. |
130 | HarmonyOS PC | Run the Linux ARM64 build inside the Linux subsystem (融合开发引擎), or build natively for `aarch64-unknown-linux-ohos` and sign it; see [HarmonyOS and OpenHarmony](HarmonyOS.md). |
131 | `curl` (or `wget`) and `sha256sum` (or `shasum`) | The installer uses them to download and verify. |
132 | A model provider key, e.g. [DeepSeek](https://platform.deepseek.com/api_keys) | Codewhale does nothing useful without a model. |
133 | `git` (recommended) | Codewhale works best inside a git repository. |
134 | Optional: Python 3, Node.js 20+ | If present, Codewhale enables its Python and JS execution tools (`codewhale doctor` lists them). |
135
136 **Which install path?**
137
138 * **Most people:** the [recommended installer](#2-recommended-installer-curl--sh).
139 It's the fastest (about 6 s here), verifies checksums, and supports
140 `codewhale update`.
141 * **Air-gapped or security-reviewed machines:**
142 [manual download](#3-manual-download-from-github-releases).
143 * **You already manage CLI tools with npm:** [npm](#4-npm).
144 * **No prebuilt binary for your platform, or you want to build it yourself:**
145 [Cargo](#5-cargo-and-building-from-source).
146
147 Pick **one**. Several installs on one machine end up fighting over PATH (see
148 [Troubleshooting](#13-troubleshooting)).
149
150 **Privacy note:** Codewhale sends aggregate usage counts to Codewhale's
151 first-party endpoint (`https://telemetry.codewhale.net/v1/telemetry`) **by
152 default**. To turn this off permanently:
153 `codewhale config set telemetry false`, or export `CODEWHALE_TELEMETRY=0`,
154 which always wins. The TUI also checks GitHub for updates at startup
155 (`[update] check_for_updates` in `~/.codewhale/config.toml`).
156
157 ---
158
159 <a id="recommended-official-github-releases"></a>
160
161 ## 2. Recommended installer (`curl | sh`)
162
163 **Prerequisites:** curl, `sha256sum` (Linux) or the built-in `shasum` (macOS),
164 a writable home directory. No sudo, no Node, no Rust.
165
166 ```bash
167 curl -fsSL https://codewhale.net/install.sh | sh
168 ```
169
170 What it does (verified):
171
172 * It detects your platform (`linux-x64`, `linux-arm64`, `macos-x64`,
173 `macos-arm64`). It refuses Android/Termux and riscv64 with a clear message.
174 * It downloads `codewhale-<platform>` and `codewhale-artifacts-sha256.txt` from
175 the latest GitHub Release. When the `codewhale` and `codew` manifest entries
176 have the same digest, it reuses that verified download for both command names;
177 otherwise it downloads and verifies `codew-<platform>` separately. If either
178 entry doesn't match, it stops before installing anything (`codewhale install:
179 checksum mismatch for …`).
180 * It installs `~/.local/bin/codewhale` first, then installs
181 `~/.local/bin/codew` as a hard link to `~/.local/bin/codewhale` when the
182 bytes match and the filesystem supports linking (falling back to a separate
183 copy otherwise), so updates never leave the two on different versions.
184 * It **never uses sudo.** When the install directory is not on `PATH`, it appends one
185 marked three-line block to your shell profile (see [Put it on your
186 PATH](#put-it-on-your-path)), prints exactly what it added, and skips this with
187 `--no-modify-path`. It refuses to
188 install into system or package-manager directories (`/usr/bin`,
189 `~/.cargo/bin`, Homebrew and MacPorts bin directories, `node_modules`,
190 `/nix/store`…), into your home directory or `/`, or into a directory that
191 other users or groups can write (`chmod go-w <dir>` fixes one you own). It
192 also refuses to overwrite a *different* existing `codewhale` unless you ask
193 for it with `CODEWHALE_FORCE_REINSTALL=1` (see [re-running the
194 installer](#re-running-the-installer)).
195
196 Expected output:
197
198 ```
199 Installing Codewhale for linux-x64
200 Release assets: https://github.com/codewhale-hq/CodeWhale/releases/latest/download
201 Install dir: /home/you/.local/bin
202 Checksums verified
203 Installed checksummed release commands:
204 /home/you/.local/bin/codewhale
205 /home/you/.local/bin/codew
206 …
207 PATH selects no codewhale command; this install is /home/you/.local/bin/codewhale
208
209 codewhale is not on your PATH in this shell yet.
210 Added to ~/.bashrc so new shells find codewhale (skip this with --no-modify-path):
211 # >>> codewhale PATH >>>
212 export PATH="$HOME/.local/bin:$PATH"
213 # <<< codewhale PATH <<<
214 Only those three lines were added; nothing else in the file was changed. Shells that are already open do not reread the profile.
215 To undo, run:
216 cw_tmp="$(mktemp)" && sed -e '/^# >>> codewhale PATH >>>$/{$!N;$!N;/\n# <<< codewhale PATH <<<$/d;}' ~/.bashrc > "$cw_tmp" && cat "$cw_tmp" > ~/.bashrc; rm -f "$cw_tmp"
217 PATH help: https://github.com/codewhale-hq/CodeWhale/blob/main/docs/INSTALL.md#put-it-on-your-path
218
219 Run this now, in this shell:
220 export PATH="$HOME/.local/bin:$PATH"; hash -r
221 Then check it:
222 codewhale --version
223 ```
224
225 The PATH block is always the last thing the installer prints. When your PATH already
226 selects the install, the last line is `Next: codewhale --version`. When the release you
227 installed ships an `uninstall` command, the output also says that `codewhale uninstall`
228 removes the added block; v0.10.2 has no uninstall command, so the printed `sed` command (or
229 deleting the three marked lines by hand) is how you undo it there.
230
231 ### macOS notes
232
233 Re-checked on macOS 26.1, Apple silicon (`macos-arm64`), with a fresh `HOME`:
234
235 * The installer printed `Installing Codewhale for macos-arm64`, verified
236 checksums with the system tools, and installed `codewhale` and `codew`
237 (64 MiB each, Mach-O arm64) in 4.3 s. Both report
238 `codewhale 0.10.0 (1be1a703b975)`. They ran without a Gatekeeper prompt.
239 * The core TUI works without Node; the TypeScript extension host uses Node
240 (`>=22.19` or `>=24`) or Bun when enabled.
241 * `codewhale doctor` behaves as on Linux (exit 0, `All checks complete!` with no
242 key, file-based secret store under `~/.codewhale/secrets/`), except that it
243 reports `✓ sandbox available: macos-seatbelt`.
244
245 ### Put it on your PATH
246
247 If the installer says `PATH selects no codewhale command`, `~/.local/bin` isn't
248 on your PATH **in this shell**. Both `codewhale.net/install.sh` and the
249 `install.sh` inside release archives add one marked three-line block to
250 the profile of your `$SHELL` by default, print the file and the three lines, and
251 print the command that removes them:
252
253 | `$SHELL` | File edited |
254 | --- | --- |
255 | zsh | `~/.zshrc` (`$ZDOTDIR/.zshrc` when `ZDOTDIR` is set) |
256 | bash on Linux | `~/.bashrc` |
257 | bash on macOS | the first that exists of `~/.bash_profile`, `~/.bash_login`, `~/.profile` (else `~/.bash_profile`) |
258 | sh, dash, ksh, ash | `~/.profile` |
259
260 Only those three lines are appended (after a newline if the file did not end in one);
261 no other line is rewritten or reordered. The installer does not edit anything when:
262
263 * you pass `--no-modify-path` (or set `CODEWHALE_NO_MODIFY_PATH=1`); with the web installer
264 write `curl -fsSL https://codewhale.net/install.sh | sh -s -- --no-modify-path`. It then
265 prints the `printf` command for you to run yourself;
266 * the install directory is already on `PATH`;
267 * the profile is a symlink, is not a writable regular file, or its folder is missing. The
268 command is printed instead;
269 * your shell is fish or another shell it has no profile for, `$SHELL` is empty, or the
270 directory name contains quotes, `$`, backticks or backslashes. The installer says what to
271 add yourself (`fish_add_path ~/.local/bin` for fish).
272
273 Release archives older than 0.10.3 do
274 not do this: their `install.sh` takes no options, never edits a profile and only prints the
275 current-shell `export` line, and their `install.ps1` tells you to add the directory yourself.
276 Run the `printf` line in the block below to add the same three lines by hand.
277
278 Running the installer again never adds a second block: it sees the marker line and leaves
279 the file as is. A profile change does not reach shells that are already open, so the
280 installer's last lines give the `export` command for the current shell and `codewhale --version`.
281
282 To undo it by hand, delete the three lines between and including the markers, or run the
283 command the installer printed:
284
285 ```bash
286 printf '%s\n' '# >>> codewhale PATH >>>' 'export PATH="$HOME/.local/bin:$PATH"' '# <<< codewhale PATH <<<' >> ~/.bashrc # what the installer appended (bash; zsh: ~/.zshrc)
287 cw_tmp="$(mktemp)" && sed -e '/^# >>> codewhale PATH >>>$/{$!N;$!N;/\n# <<< codewhale PATH <<<$/d;}' ~/.bashrc > "$cw_tmp" && cat "$cw_tmp" > ~/.bashrc; rm -f "$cw_tmp" # undo
288 export PATH="$HOME/.local/bin:$PATH"; hash -r # this shell only
289 command -v codewhale codew
290 ```
291
292 On Ubuntu and Debian, `~/.profile` adds `~/.local/bin`, but only if the directory existed
293 when you *logged in*, and a new terminal **window** on a desktop (GNOME Terminal, Ghostty, …)
294 starts a non-login shell that reads `~/.bashrc`, not `~/.profile`. That is why the block goes
295 in `~/.bashrc` on Linux.
296
297 The three-line block is marked so `codewhale uninstall` can remove exactly it. A bare
298 `export PATH=…` line is yours: uninstall never touches it, because other tools share `~/.local/bin`.
299 `codewhale uninstall` exists in Codewhale 0.10.3 and later; on 0.10.2 use the command above.
300
301 ### Options
302
303 ```bash
304 # Choose the directory (must be absolute; created if missing)
305 curl -fsSL https://codewhale.net/install.sh | CODEWHALE_INSTALL_DIR="$HOME/.local/codewhale/bin" sh
306 # Install a specific release
307 curl -fsSL https://codewhale.net/install.sh | CODEWHALE_VERSION=v0.9.13 sh
308 # Show help
309 curl -fsSL https://codewhale.net/install.sh | sh -s -- --help
310 ```
311
312 ### Verify
313
314 ```bash
315 codewhale --version # codewhale 0.10.0 (1be1a703b975)
316 codew --version # same
317 codewhale doctor # diagnostics; see the note in §8 about what it does NOT check
318 ```
319
320 ### Re-running the installer
321
322 * Same version already installed: harmless. It prints
323 `Already installed: …` and exits 0.
324 * An earlier Codewhale already installed (a regular file you own that is a
325 Codewhale release binary, with or without an install receipt): the
326 installer **upgrades** it. The old `codewhale`, `codew` and receipt move to
327 `~/.codewhale/recovery/<UTC stamp>/` (kept 30 days, never left beside the
328 commands on PATH), the new release is installed with a fresh receipt, and the
329 last lines print the undo command
330 (`codewhale doctor --restore <stamp>`) and a short report of any other copies
331 on the machine (`codewhale doctor --installs --brief`).
332 * A symlink, a file owned by another user, or a file that is not a Codewhale
333 binary at the destination is **refused** and left unchanged. Install into a
334 fresh directory, or set `CODEWHALE_FORCE_REINSTALL=1` to move a regular file
335 you own to the recovery folder and install anyway. A managed directory
336 (npm, Cargo, Homebrew, system paths) is always refused.
337 * Not a release build, at the same version (a local `cargo build` reports
338 `0.10.2 (dev)`): `codewhale update` still reinstalls the release artifact
339 over it, because that build has no release provenance to preserve.
340
341 ### Upgrade / uninstall
342
343 * Upgrade: automatic for this install (see §7), or `codewhale update` now.
344 * Uninstall (0.10.3 and later): `~/.local/bin/codewhale uninstall` previews the receipt-owned
345 files; add `--yes` to remove them. On 0.10.2 or earlier there is no such command (the word
346 would start a chat): run `rm ~/.local/bin/codewhale ~/.local/bin/codew ~/.local/bin/.codewhale-install.sha256`.
347 See §12 for data.
348
349 ---
350
351 ## 3. Manual download from GitHub Releases
352
353 Use this when you want to see and verify every byte yourself. Releases:
354 <https://github.com/codewhale-hq/CodeWhale/releases>. Each platform has **bare
355 binaries** (`codewhale-linux-x64`, `codew-linux-x64`, …) and an **archive**
356 (`codewhale-linux-x64.tar.gz`) that holds the same two binaries plus an
357 `install.sh`.
358
359 ### 3a. Bare binaries
360
361 ```bash
362 mkdir -p ~/codewhale-dl && cd ~/codewhale-dl
363 base=https://github.com/codewhale-hq/CodeWhale/releases/latest/download
364 curl -fsSLO "$base/codewhale-linux-x64" # use linux-arm64 on ARM
365 curl -fsSLO "$base/codew-linux-x64"
366 curl -fsSLO "$base/codewhale-artifacts-sha256.txt"
367 sha256sum -c codewhale-artifacts-sha256.txt --ignore-missing
368 # codew-linux-x64: OK
369 # codewhale-linux-x64: OK
370 mkdir -p ~/.local/bin
371 install -m 755 codewhale-linux-x64 ~/.local/bin/codewhale
372 install -m 755 codew-linux-x64 ~/.local/bin/codew
373 ```
374
375 Then [put `~/.local/bin` on PATH](#put-it-on-your-path) and run
376 `codewhale --version`. On macOS the assets are `codewhale-macos-arm64` and
377 `codew-macos-arm64` (`-macos-x64` on Intel), and the built-in `shasum` verifies
378 them (tested on macOS 26.1, Apple silicon):
379
380 ```bash
381 /usr/bin/shasum -a 256 -c codewhale-artifacts-sha256.txt --ignore-missing
382 # codew-macos-arm64: OK
383 # codewhale-macos-arm64: OK
384 ```
385
386 The `codewhale-macos-arm64.tar.gz` archive verifies the same way against
387 `codewhale-bundles-sha256.txt`, and its `./install.sh` installs into
388 `~/.local/bin` (tested).
389
390 To pin a release, replace `latest/download` with `download/vX.Y.Z`, and take
391 the manifest from the same tag.
392
393 ### 3b. Archive
394
395 ```bash
396 cd "$(mktemp -d)"
397 base=https://github.com/codewhale-hq/CodeWhale/releases/latest/download
398 curl -fsSLO "$base/codewhale-linux-x64.tar.gz"
399 curl -fsSLO "$base/codewhale-bundles-sha256.txt" # note: *bundles*, not *artifacts*
400 sha256sum -c codewhale-bundles-sha256.txt --ignore-missing
401 # codewhale-linux-x64.tar.gz: OK
402 tar -xzf codewhale-linux-x64.tar.gz
403 cd codewhale-linux-x64 && ./install.sh # -> ~/.local/bin; PREFIX=/some/dir ./install.sh -> /some/dir/bin
404 ```
405
406 The archive's `install.sh` never uses sudo, leaves differing existing files
407 alone and asks nothing. Like the web installer, it adds the
408 marked PATH block to your shell profile when the directory is not on `PATH`
409 (`./install.sh --no-modify-path` skips that). (Archives older than 0.10.3 take no
410 options and only print an `export` line for the current shell; see
411 [Put it on your PATH](#put-it-on-your-path).)
412
413 **Upgrade:** `codewhale update` works for both 3a and 3b, because they're
414 "direct binary" installs. **Uninstall:** delete the two files (see §12).
415
416 ---
417
418 ## 4. npm
419
420 **Prerequisites:** Node.js 22+ and npm, with a **global prefix you can write
421 to**. On Node.js 18 or 20 the install stops and asks you to upgrade Node.js.
422 npm installs the registry's latest published version, never an
423 unpublished source candidate.
424
425 ```bash
426 npm install -g codewhale
427 codewhale --version
428 ```
429
430 The package is a small wrapper. Its `postinstall` step downloads the same
431 `codewhale`/`codew` release binaries, checks them against the release's SHA-256
432 manifest, and links `codewhale` and `codew` into npm's global `bin`. The whole
433 thing took 6 s here.
434
435 **Windows npm sessions:** Node remains the native program's launcher for the
436 whole session. A process-name kill such as `taskkill /IM node.exe` or
437 `Get-Process node | Stop-Process -Force` can interrupt this and other npm
438 Codewhale sessions and prevent normal terminal cleanup. Stop only the server
439 PID you started or the process owning its port, or use Codewhale's task
440 cancellation. The Windows
441 native archive/installer avoids this npm-parent dependency; this does not
442 remove Node requirements for optional JavaScript tools. Codewhale's Windows
443 shell safety floor holds recognized image-wide Node kills even in Full Access.
444 An external hard kill or an arbitrary program that terminates the launcher
445 cannot be made graceful by this shell-command check.
446
447 ### If you get `EACCES: permission denied`
448
449 That means Node is installed system-wide (apt, `/usr/local`, `/opt`), and your
450 user can't write to its global prefix:
451
452 ```
453 npm error code EACCES
454 npm error Error: EACCES: permission denied, mkdir '/opt/node22/lib/node_modules/codewhale'
455 ```
456
457 **Don't use `sudo npm`.** Either use a per-user Node (nvm, fnm, volta), or
458 point npm at a directory you own. I tested the second option:
459
460 ```bash
461 npm config set prefix "$HOME/.npm-global"
462 echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
463 export PATH="$HOME/.npm-global/bin:$PATH"
464 npm install -g codewhale
465 command -v codewhale codew # ~/.npm-global/bin/codewhale, ~/.npm-global/bin/codew
466 ```
467
468 ### Notes
469
470 * npm hides the download progress. Add `--foreground-scripts` to see it
471 (`codewhale: selected GitHub Releases for v0.10.0 … done.`). The chosen
472 source is also written to
473 `$(npm prefix -g)/lib/node_modules/codewhale/bin/downloads/codewhale.source`.
474 * The package uses 157 MB on disk.
475 * On macOS 26.1 (Apple silicon, Homebrew Node 25) an install into a user-owned
476 prefix (`npm install -g --prefix <dir> codewhale`) took 3 s and linked
477 `codewhale` and `codew`, both `codewhale 0.10.0 (1be1a703b975)`.
478 * **Upgrade:** `npm install -g codewhale@latest`. `codewhale update` refuses
479 on npm installs. It prints the one command that updates it, ends with
480 `Not updated: use the command above.` and exits 1 (`codewhale uninstall` does
481 the same for these copies: `Not removed: use the command above.`, exit 1)
482 * **Specific version:** `npm install -g codewhale@0.9.13`.
483 * **Uninstall:** `npm uninstall -g codewhale`. This removes only the program,
484 not your data (§12).
485
486 ---
487
488 <a id="4-install-via-cargo-any-tier-1-rust-target"></a><a id="7-build-from-source"></a>
489
490 ## 5. Cargo and building from source
491
492 Use this if there's no prebuilt binary for your platform, or you want to
493 compile it yourself. One Cargo package is required:
494 `codewhale-cli` installs the `codewhale` command. npm and prebuilt releases also
495 expose `codew` as a convenience name for the same compiled runtime; Cargo does
496 not create that alias, so add `alias codew=codewhale` to your shell rc if you
497 want the short name.
498
499 ### Prerequisites (Debian/Ubuntu)
500
501 ```bash
502 sudo apt-get install -y build-essential pkg-config libdbus-1-dev git
503 # Rust via rustup (the distro's cargo is too old for this edition-2024 workspace)
504 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
505 source "$HOME/.cargo/env"
506 rustc --version # the workspace declares rust-version = 1.89
507 ```
508
509 `libdbus-1-dev` **is required**. Without it the build fails after about a
510 minute with:
511
512 ```
513 error: failed to run custom build command for `libdbus-sys v0.2.7`
514 The system library `dbus-1` required by crate `libdbus-sys` was not found.
515 ```
516
517 Fedora/RHEL: `sudo dnf install -y gcc make pkgconf-pkg-config dbus-devel`
518 **(untested on this VM: Ubuntu only)**.
519
520 ### 5a. From crates.io
521
522 ```bash
523 cargo install codewhale-cli --locked
524 codewhale --version
525 ```
526
527 Tested result: **works**, with current stable Rust (1.98.1).
528 * It took **25 min 31 s** on 4 vCPU and 15 GB RAM, and pulled about 470 MB
529 into `~/.cargo/registry`.
530 * It installs one 122 MB file, `~/.cargo/bin/codewhale`. That's a normal
531 glibc-linked binary, and it needs `libdbus-1` at runtime.
532 * `codewhale --version` prints `codewhale 0.10.0`, with no commit hash.
533 * Headless and TUI smoke tests passed.
534
535 > **v0.10.0 declared "Rust 1.88+", which was wrong.** The workspace now
536 > declares 1.89, the version CI's MSRV job builds. With 1.88.0 the v0.10.0
537 > install fails in seconds:
538 > `rustc 1.88.0 is not supported by the following package: serde-saphyr@1.3.0 requires rustc 1.89`.
539 > Use current stable (`rustup update stable`).
540
541 ### 5b. From a git checkout
542
543 ```bash
544 git clone --depth 1 --branch v0.10.0 https://github.com/codewhale-hq/CodeWhale.git
545 cd CodeWhale
546 cargo install --path crates/cli --locked # installs ~/.cargo/bin/codewhale
547 ```
548
549 Things to know (observed):
550
551 * The repo contains `rust-toolchain.toml` (`channel = "1.100.0"`). With rustup,
552 the first `cargo` command inside the checkout **silently downloads Rust
553 1.100.0** (about 250 MB) if you do not have it, whatever your default is.
554 * The workspace treats every compiler warning as an error. The declared
555 minimum is Rust 1.89, which CI's MSRV job checks, but release binaries and
556 the repository's own checks use 1.100.0. Without rustup, use rustc 1.89 or
557 newer.
558 * The workspace release profile uses thin LTO. On a 4-vCPU / 15 GB VM, the
559 `codewhale-tui` crate alone compiled for more than an hour, peaking at
560 6–8 GB of RAM. Budget 16 GB or more, and expect this to be the slowest install
561 path by far. `target/` grew past 1.2 GB.
562
563 Tested result: **works** on Rust 1.98.1, the version the repository selected when this was measured.
564 * `Finished release profile … in 83m 12s`. A Nix build competed for CPU and
565 memory for most of that time, so treat it as an upper bound.
566 * `target/` ended at **3.1 GB**. Delete it afterwards with `cargo clean`.
567 * The binary reports `codewhale 0.10.0 (dev)`, and `exec` worked.
568 * Cargo prints `warning: default toolchain implicitly overridden with
569 1.100.0-x86_64-unknown-linux-gnu by rustup toolchain file`, which is harmless.
570 * **Cargo builds provide no `codew`.**
571
572 **Upgrade:** re-run the same `cargo install … --force` (for crates.io, you can
573 add `--version X.Y.Z`). `codewhale update` refuses Cargo installs.
574 **Uninstall:** `cargo uninstall codewhale-cli`, then §12.
575
576 ---
577
578 ## 6. Homebrew on Linux and Nix
579
580 ### Homebrew on Linux: works, but not with the command the old docs gave
581
582 Prerequisite: Homebrew itself. Its installer needs sudo **once**, to create
583 `/home/linuxbrew/.linuxbrew`. Without sudo rights it stops with
584 `Insufficient permissions to install Homebrew to "/home/linuxbrew/.linuxbrew"`.
585 Ask an admin to run
586 `sudo mkdir -p /home/linuxbrew/.linuxbrew && sudo chown $USER /home/linuxbrew/.linuxbrew`,
587 then re-run the installer. Afterwards, add
588 `eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"` to `~/.bashrc`,
589 as its "Next steps" say.
590
591 ```bash
592 brew install Hmbown/deepseek-tui/codewhale # full name: taps and trusts in one step
593 ```
594
595 The two-step form (`brew tap Hmbown/deepseek-tui` then `brew install
596 codewhale`) **fails on Homebrew 7.x**:
597
598 ```
599 Error: Refusing to load formula hmbown/deepseek-tui/codewhale from untrusted tap hmbown/deepseek-tui.
600 Run `brew trust --formula hmbown/deepseek-tui/codewhale` or `brew trust hmbown/deepseek-tui` to trust it.
601 ```
602
603 Run `brew trust hmbown/deepseek-tui` first, or use the full name above.
604
605 Tested with Homebrew 7.0.6 against the v0.10.0 tap formula: the install took
606 73 s. The tap formula tracks the latest release and downloads the official
607 release binaries, so there's no compile. It provides **both** `codewhale` and
608 `codew`. The `Hmbown/deepseek-tui` tap formula also depends on `node`, which
609 pulled in 31 bottles (~560 MB) on Linux. That `node` dependency belongs to
610 this tap formula only. The core TUI runs without Node; the JS execution tool
611 uses it when it is on PATH.
612
613 * **Upgrade:** `brew upgrade codewhale`. (`codewhale update` refuses, and
614 suggests migrating.)
615 * **Uninstall:** `brew uninstall codewhale && brew untap Hmbown/deepseek-tui`.
616 This also autoremoves the tap's node dependency and anything else it pulled
617 in. Homebrew's
618 download cache (`~/.cache/Homebrew`, ~330 MB) stays until
619 `brew cleanup --prune=all`.
620
621 ### Nix: partially tested
622
623 ```bash
624 # flakes are still experimental; the tested setup enabled them once:
625 mkdir -p ~/.config/nix
626 echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
627 nix run github:codewhale-hq/CodeWhale -- --version
628 # one-off alternative (untested on this VM): nix --extra-experimental-features 'nix-command flakes' run github:codewhale-hq/CodeWhale -- --version
629 ```
630
631 Nix 2.35 installed fine; single-user mode needs `/nix` created by root once.
632 Flakes resolved. What I learned before stopping:
633
634 * There's **no binary cache**, so this is a full source build of the
635 **main branch**, not the v0.10.0 release. The binary reports
636 `codewhale 0.10.0 (dev)`.
637 * The build step took 30 min on 4 cores. The package then runs its **test
638 suite** (`doCheck`), which recompiles the workspace in test mode. That took
639 over 70 minutes and more than 8 GB of RAM for one rustc process, and I
640 stopped it at 105 minutes. So `nix run` completing, `nix build`, and
641 `nix profile install/remove` are **(untested on this VM: build did not
642 finish in the time budget; the VM's proxy also required an
643 `--override-input fenix …` workaround)**.
644 * Nix provides only `codewhale`; there's no `codew` (it builds just the
645 `codewhale-cli` package).
646
647 Unless you already live in Nix, use §2 instead.
648
649 ---
650
651 ## 7. Updating and rolling back
652
653 These work for installs from §2 and §3 (direct binaries). Package-manager
654 installs (npm, Cargo, Homebrew) must be updated with their own tool, and the
655 Engine inside the Codewhale desktop app is updated by the app
656 (Codewhale > Check for Updates); `codewhale update` refuses to write there.
657
658 <a id="automatic-updates"></a>
659
660 ### Automatic updates
661
662 Release-binary installs update themselves:
663
664 1. When the TUI starts it checks for a newer release at most every 6 hours
665 (`[update] check_interval_hours`). Offline or rate-limited checks keep the
666 last answer and retry about an hour later, never on every launch.
667 2. If one exists, it downloads and verifies it in the background
668 (`codewhale update --stage`, a separate low-impact process) into
669 `~/.codewhale/updates/staged/`. The header shows `↑ v0.10.4 ready`.
670 3. The next time you start `codewhale`, before any session opens, the staged
671 binary replaces the installed one. A running session is never touched.
672 You see one line:
673 `Updated to v0.10.5 · What's new: https://codewhale.net/en/changelog/0.10.5 · Undo: codewhale update --rollback (back to v0.10.4)`.
674 The Undo part appears only when the kept version can be rolled back to.
675 v0.10.3 and later refuse to roll back to v0.10.3 or earlier, because
676 workspace state they migrated cannot be checked against those releases;
677 the line then says `No rollback: …` instead, and `codewhale doctor` says
678 the same.
679
680 **Signed releases apply automatically; unsigned builds wait for your OK.** Starting with v0.10.5, Codewhale compiles the release Ed25519 public key into the binary and verifies `codewhale-artifacts-sha256.txt.sig` before installing, refusing any release whose signature is missing or does not verify. Older builds without the release key still verify the SHA-256 checksum and ask once on the next start (`Install v0.10.5 now? [y/N]`, no unless you type y); you can also run `/update install` or `codewhale update`. Say no and it does not ask again for that version. The checksum manifest always comes from GitHub Releases; the CNB mirror can only supply a binary whose SHA-256 that manifest already lists. Non-interactive starts never prompt and never apply an unsigned update.
681
682 Turn it down or off:
683
684 Needs Codewhale 0.10.3 or later; 0.10.2 has no `update.mode` key.
685
686 ```bash
687 codewhale config set update.mode notify # tell me about updates, don't download
688 codewhale config set update.mode off # no update checks at all
689 export CODEWHALE_UPDATE_MODE=notify # same, per environment
690 ```
691
692 `CODEWHALE_NO_UPDATE_CHECK=1` and CI environments also turn checks off.
693
694 **Organizations** can set the mode for every user of a machine in a
695 root-owned, not group/world-writable policy file that wins over user settings:
696 `/Library/Application Support/Codewhale/policy.toml` (macOS),
697 `/etc/codewhale/policy.toml` (Linux and macOS) or
698 `%ProgramData%\Codewhale\policy.toml` (Windows):
699
700 ```toml
701 [update]
702 mode = "off" # auto | notify | off
703 ```
704
705 An unreadable or malformed policy file means `off`. `codewhale doctor` shows
706 the mode in force and where it came from, any staged update, and the version
707 kept for rollback.
708
709 Package-manager and desktop-app copies never download or replace anything;
710 the notice names their own command instead.
711
712 ```bash
713 codewhale update --check
714 # Current binary: /home/you/.local/bin/codewhale
715 # Current version: v0.9.13
716 # Latest stable release: v0.10.0
717 # Update available. Run `/home/you/.local/bin/codewhale update` to install v0.10.0.
718 codewhale update
719 # Downloading codewhale-linux-x64...
720 # SHA256 checksum verified against codewhale-artifacts-sha256.txt from GitHub Releases.
721 # ✅ Successfully updated to v0.10.0!
722 # Updated binaries:
723 # - /home/you/.local/bin/codewhale (codewhale-linux-x64)
724 # - /home/you/.local/bin/codew (codewhale-linux-x64)
725 ```
726
727 It updates `codewhale` **and** `codew` together. If `codew` is a different
728 Codewhale build than `codewhale`, the old `codew` moves to the recovery folder
729 and is replaced, instead of the update refusing. An install from before
730 receipts gets one (`.codewhale-install.sha256`), so `codewhale uninstall` can
731 remove it later. It took 10 s here. Run it again and you get
732 `Already up to date; no download needed.` Other options: `--beta` and
733 `--proxy <URL>`.
734
735 A build that is not a published release reports its provenance in
736 `codewhale --version` (`0.10.2 (dev)` for a local build, a commit hash for a
737 release). `codewhale update` compares the release, not just the version, so a
738 same-version `(dev)` build is replaced by the release artifact instead of
739 reporting "Already up to date" forever.
740
741 <a id="roll-back-to-a-previous-release"></a>
742
743 ### Rolling back (e.g. to v0.9.13)
744
745 Every update, automatic or manual, keeps the version it replaced in
746 `~/.codewhale/updates/previous/`. To go back one version:
747
748 ```bash
749 codewhale update --rollback
750 # Rolled back to v0.10.4. v0.10.5 will not be installed automatically again; the next newer release will.
751 ```
752
753 Run it again to swap forward. `codewhale update` never downgrades, and
754 `CODEWHALE_VERSION=0.9.13 codewhale update` just says "Already up to date". To
755 go back further than one version, replace the files:
756
757 ```bash
758 dir="$(dirname "$(command -v codewhale)")" # the install PATH actually selects
759 mkdir -p "$dir/.keep" && mv "$dir/codewhale" "$dir/codew" "$dir/.keep/"
760 curl -fsSL https://codewhale.net/install.sh | CODEWHALE_VERSION=v0.9.13 CODEWHALE_INSTALL_DIR="$dir" sh \
761 && rm -r "$dir/.keep" \
762 || mv "$dir/.keep/codewhale" "$dir/.keep/codew" "$dir/" # restore on failure
763 hash -r; codewhale --version # codewhale 0.9.13 (a0b81f619b66)
764 ```
765
766 Tested with both the default `~/.local/bin` and a custom
767 `CODEWHALE_INSTALL_DIR`. Use it only for installer, manual or archive
768 installs. Never point it at an npm, Cargo or Homebrew directory.
769
770 Or keep both versions side by side, and put the old one first on PATH:
771
772 ```bash
773 curl -fsSL https://codewhale.net/install.sh | CODEWHALE_VERSION=v0.9.13 CODEWHALE_INSTALL_DIR="$HOME/.local/codewhale-0.9.13" sh
774 export PATH="$HOME/.local/codewhale-0.9.13:$PATH"; hash -r
775 ```
776
777 To return to the latest after an in-place rollback, run `codewhale update`.
778 (Tested: 0.9.13 → 0.10.0.)
779
780 npm: `npm install -g codewhale@0.9.13`. Cargo:
781 `cargo install codewhale-cli --version 0.9.13 --locked --force` **(untested on
782 this VM: only 0.10.0 was built)**.
783
784 <a id="clean-up-old-copies"></a>
785
786 ### Clean up old copies
787
788 `codewhale doctor` has an **Installations** section, and
789 keeps routine path and secret-backend details brief. Use `codewhale doctor --all`
790 to show every resolved path and structural secret-backend detail.
791
792 `codewhale doctor --installs` prints only that (`--json` for machines,
793 `--brief` for nothing on a tidy machine). It lists every `codewhale`, `codew`,
794 `codewhale-tui`, `deepseek` and `deepseek-tui` in your `PATH`, `~/.local/bin`,
795 `~/.cargo/bin` and beside the running binary, says which one your shell runs,
796 and classifies each: receipt-owned, unreceipted Codewhale, backup, managed by a
797 package manager (with that manager's exact removal command), part of the
798 desktop app, or left alone (symlinks, other programs such as `codewhale-go`,
799 files of other users). It never runs a file it finds; a copy whose bytes
800 differ from the running one is reported as "version unknown".
801
802 `codewhale doctor --fix` shows one plan and asks once (`[Y/n]`). For
803 installations it can:
804
805 * move old backups (`codewhale.bak-…`, `codewhale-0.8.60.bak`,
806 `codewhale.pre-v…`, `codewhale.old-<pid>`, `.codewhale-backup-*` folders and
807 similar) into `~/.codewhale/recovery/<UTC stamp>/`;
808 * make an unreceipted `codew` match the `codewhale` beside it (old copy to
809 recovery) and record an install receipt for that directory.
810
811 Every move prints its own undo command; `codewhale doctor --restore <stamp>`
812 (or `--restore` for the newest) puts the whole folder back. Recovery folders
813 are deleted by a later `doctor --fix` after 30 days, and `doctor` shows when.
814 Nothing is deleted on the spot, user data (`~/.codewhale`, `~/.deepseek`) is
815 never touched, and package-managed, desktop-app and foreign files are only
816 reported.
817
818 <a id="release-signing"></a>
819
820 ### Release signing (maintainers)
821
822 The Engine verifies `codewhale-artifacts-sha256.txt.sig`, a base64 Ed25519
823 signature over `codewhale-release-manifest-v1\n<version>\n<manifest bytes>`
824 (`crates/release/src/signing.rs`). Releases are signed from 0.10.5, and the
825 release public key is compiled in as `TRUSTED_RELEASE_KEYS`:
826
827 - A build that carries the key refuses a release whose signature is missing or
828 does not verify, in `codewhale update` and in automatic updates. Nothing is
829 installed and the message names the signature file.
830 - A build from before 0.10.5 trusts no key, so the update to 0.10.5 itself
831 still asks once before installing.
832 - From 0.10.5 on, the next release installs without asking.
833
834 Every release after 0.10.5 must therefore be signed with this key. macOS
835 desktop updates do not use it: they are trusted by Developer ID signing.
836
837 How the key is set up:
838
839 1. The key is created offline with OpenSSL 3 and its private half stays
840 outside any repository:
841 `openssl genpkey -algorithm ed25519 -out codewhale-release-ed25519.pem`
842 2. The PEM file's contents are the GitHub Actions secret
843 `CODEWHALE_RELEASE_SIGNING_KEY` on the Engine repository. The release
844 workflow (`release-artifacts.yml`, assemble job) then runs
845 `scripts/release/sign-release-manifest.sh` and publishes the `.sig`
846 beside the manifest; without the secret it skips signing and says so.
847 3. The public key is printed with
848 `CODEWHALE_RELEASE_SIGNING_KEY="$(cat codewhale-release-ed25519.pem)" scripts/release/sign-release-manifest.sh --public-key`
849 and listed in `TRUSTED_RELEASE_KEYS` in `crates/release/src/signing.rs`
850 (a build can add one more with `CODEWHALE_RELEASE_PUBLIC_KEY=<hex>`).
851
852 To rotate, add the new public key next to the old one, release, then switch
853 the secret and remove the old key a release later.
854
855 ---
856
857 ## 8. API keys and providers
858
859 ### Where Codewhale looks for a key (first match wins)
860
861 1. `--api-key <KEY>` on the command line
862 2. `api_key` in `~/.codewhale/config.toml`
863 3. the secret store written by `codewhale auth set`
864 4. the environment variable (`DEEPSEEK_API_KEY` for DeepSeek)
865
866 This order matters. **A key in config or the secret store beats
867 `DEEPSEEK_API_KEY`.** If you rotate your key by exporting a new env var, an
868 old stored key keeps being used. I tested this: a wrong key in `config.toml`
869 plus the correct env var gives `Authentication Fails … ****beef is invalid`.
870
871 ### Ways to set a DeepSeek key (all tested)
872
873 **Environment variable.** Good for trying it out and for CI:
874 ```bash
875 export DEEPSEEK_API_KEY=sk-... # add to ~/.bashrc / ~/.zshenv to persist
876 ```
877
878 **`auth set`.** Saves the key for every folder:
879 ```bash
880 codewhale auth set --provider deepseek # prompts: "Enter API key for deepseek:"
881 printf '%s\n' "$KEY" | codewhale auth set --provider deepseek --api-key-stdin # scripted
882 # -> saved API key for deepseek to file-based ("/home/you/.codewhale/secrets/secrets.json") (config contains metadata only)
883 ```
884 The file-based message prints the resolved secret-store path; an explicit
885 `CODEWHALE_HOME` changes that location.
886
887 On Linux, the key is stored in **plaintext** in
888 `~/.codewhale/secrets/secrets.json`, with mode 0600. It is not in an OS
889 keyring. Note that in v0.10.0, `auth set` also writes
890 `default_text_model = "deepseek-v4-pro"` into your config, switching you from
891 the default `deepseek-flash` to the pricier Pro model. Change it back with
892 `/model` in the TUI, or edit `~/.codewhale/config.toml`.
893
894 **Inside the TUI.** Press **F3** (or type `/provider`), select DeepSeek, press
895 Enter, paste the key (masked), pick a model, and confirm. This also writes the
896 secret store, and keeps `deepseek-flash`.
897
898 **Config file.** `~/.codewhale/config.toml`:
899 ```toml
900 [providers.deepseek]
901 api_key = "sk-..."
902 ```
903
904 ### Check which key is active
905
906 ```bash
907 codewhale auth status --provider deepseek
908 # active source: env (last4: ...xxxx) # or: secret store / config / missing
909 # lookup order: config -> secret store -> env
910 codewhale doctor --probe-api
911 # · Testing connection... ✓ API connection successful
912 ```
913
914 Plain `codewhale doctor` names an environment key it can see
915 (`deepseek: env_source=set via DEEPSEEK_API_KEY (value not shown; not checked offline)`)
916 but does not read the secret store or check the key; `--probe-api` does both.
917 Doctor exits 0 even when no key is found, so scripts should use `auth status`.
918
919 ### Remove a stored key
920
921 ```bash
922 codewhale auth clear --provider deepseek
923 # cleared API key for deepseek from config and secret store
924 ```
925
926 It doesn't unset `DEEPSEEK_API_KEY` in your shell, and it leaves the
927 `default_text_model` line that `auth set` added.
928
929 ### Other providers
930
931 `codewhale auth list` shows about 50 providers (OpenRouter, Anthropic, OpenAI,
932 Moonshot, Ollama, …). The pattern is the same:
933 `codewhale auth set --provider <name>`, or the provider's env var. Local models
934 (Ollama, vLLM, SGLang) need no key. Only DeepSeek was tested here.
935
936 ---
937
938 <a id="8-shell-completions"></a>
939
940 ## 9. Shell completions
941
942 ```bash
943 # bash (needs the bash-completion package)
944 mkdir -p ~/.local/share/bash-completion/completions
945 codewhale completion bash > ~/.local/share/bash-completion/completions/codewhale
946
947 # zsh
948 mkdir -p ~/.zfunc
949 codewhale completion zsh > ~/.zfunc/_codewhale
950 # in ~/.zshrc, if not already there:
951 # fpath=(~/.zfunc $fpath)
952 # autoload -Uz compinit && compinit
953
954 # fish
955 mkdir -p ~/.config/fish/completions
956 codewhale completion fish > ~/.config/fish/completions/codewhale.fish
957 ```
958
959 Each script registers both `codewhale` and `codew`. `codewhale completions` is
960 an alias. Open a new shell afterwards. Regenerate after upgrading.
961
962 How well they work in v0.10.0 (tested interactively):
963
964 * **bash:** fully works (`codewhale comp<Tab>`, `codew auth <Tab><Tab>`).
965 * **fish:** sub-commands complete with descriptions, but
966 `codewhale completion <Tab>` offers files instead of shell names.
967 * **zsh:** only the first word completes. After a sub-command
968 (`codewhale auth <Tab>`), zsh wrongly lists the top-level commands again
969 (same on macOS zsh 5.9, where it offers all 126 top-level entries).
970
971 PowerShell and Elvish scripts are generated too **(untested on this VM: shells
972 not installed)**.
973
974 ---
975
976 ## 10. Running it
977
978 ### The TUI
979
980 ```bash
981 cd your-git-repo
982 codewhale
983 ```
984
985 * The composer is at the bottom. The footer shows the permission dial stop
986 (`accept edits`) and the model (`DeepSeek · deepseek-flash`).
987 * **Shift+Tab** steps the permission dial: Ask → Accept Edits → Plan →
988 Auto-Review → Full Access. Plan is read-only planning; every other stop is
989 Work. **Tab** only completes commands and file mentions.
990 * In **Ask**, file edits and shell commands stop at an **APPROVAL** prompt:
991 `y` allow once, `a` allow for this session, `n` deny, `Esc` abort the turn.
992 In **Accept Edits**, file edits in the repository are applied and shown as a
993 diff, and shell commands still prompt.
994 * Useful keys: **F1** help (or `/help`), **Ctrl-K** command palette, **F3**
995 provider/model picker, **Ctrl-R** resume a past session, **Ctrl-U** clear the
996 input (**Ctrl-Z** restores it), **Ctrl-C** cancel, clear the draft, or quit, **Ctrl-D** quit
997 with an empty input. Full list: [KEYBINDINGS.md](KEYBINDINGS.md).
998 * On exit it prints `To resume this session, run codewhale resume <id>`.
999
1000 Codewhale creates a `.codewhale/` directory in your repo. Ignore its contents
1001 but keep the committable `constitution.json` (these are the same patterns
1002 `/init` writes):
1003
1004 ```gitignore
1005 **/.codewhale/*
1006 !**/.codewhale/constitution.json
1007 ```
1008
1009 ### Headless (scripts, CI)
1010
1011 ```bash
1012 codewhale exec "summarize what src/ contains" # agent run with tools, under your sandbox and approval settings
1013 codewhale exec --no-tools "Reply with exactly: pong" # one answer, no tools
1014 codewhale exec --auto "create primes.py that prints the first 10 primes and run it" # tools, auto-approved
1015 codewhale exec --json "…" # summary JSON (provider, model, usage, output)
1016 codewhale exec --auto --output-format stream-json "…" # one JSON event per line
1017 codewhale exec --json-schema '{"type":"object"}' "…" # fail-closed JSON Schema output
1018 ```
1019
1020 `--auto` enables Full Access by default: tools run without approval, shell
1021 commands have no Codewhale sandbox, and trust mode permits file tools to write
1022 outside the workspace. Add `--sandbox workspace-write` to keep the shell
1023 sandbox and file-tool workspace restrictions, with trust mode off.
1024
1025 Plain `exec` offers the model the normal tool surface under the configured
1026 sandbox and approval posture. `--no-tools` asks for one answer with no tools;
1027 tool-only flags such as `--max-tool-calls`, `--disallowed-tools`, `--sandbox`
1028 and `--hooks` then print a warning. If the provider stops a reply at its output
1029 limit, the model is asked to continue and the printed answer is the whole
1030 reply. A `--no-tools` run takes at most 8 model steps unless `--max-turns` sets
1031 another limit; a reply still cut off at that limit fails the run.
1032
1033 ### Resuming
1034
1035 ```bash
1036 codewhale resume <session-id> # or a unique prefix, e.g. e2525dfb
1037 codewhale -c # continue the most recent session in this folder
1038 codewhale sessions # list saved sessions
1039 codewhale exec --continue "…" # headless follow-up to the latest session
1040 codewhale exec --resume <id> "…"
1041 ```
1042
1043 TUI sessions, resumed exec sessions, and exec runs that offer tools (including
1044 `exec --auto`) are saved in every output format. `--output-format stream-json`
1045 also saves answer-only runs. Use `codewhale receipts --last` for a saved run's
1046 receipt. Other answer-only text and `--json` runs are saved only if conversation
1047 compaction starts; without that, they create no session for `exec --continue`
1048 or a receipt.
1049
1050 ---
1051
1052 ## 11. Terminal notes
1053
1054 ### Ghostty (tested: Ghostty 1.3.1 on Linux/X11)
1055
1056 Everything I checked worked in Ghostty with its default config
1057 (`TERM=xterm-ghostty`, `COLORTERM=truecolor`). Screenshots are kept with the
1058 [install receipts](https://github.com/codewhale-hq/Codewhale/tree/37ecdfcc49bc68a9b0d058b97c3946e62c34bd31/docs/install-report/v0.10.0-2026-09-23/screenshots).
1059
1060 | Check | Result |
1061 |---|---|
1062 | Colours / truecolor gradient, box drawing, Unicode (✓ é 日本語) | ✅ |
1063 | Window resize (1504×886 → 800×500 → back) reflows cleanly | ✅ |
1064 | Mouse wheel scrolls the transcript, with a jump-to-bottom button | ✅ |
1065 | Paste (`Ctrl+Shift+V`), multi-line: inserted, not sent | ✅ |
1066 | F1, F3, Ctrl-K, Ctrl-R, Tab, Shift+Tab, Ctrl-U/Ctrl-Z, Ctrl-C, Ctrl-D | ✅ |
1067 | Window title shows state (`waiting on you…`, `✓ done`) | ✅ |
1068 | Exit restores the terminal (normal screen, cursor, no mouse-reporting garbage) | ✅ |
1069
1070 Ghostty on Linux starts a **non-login** shell, so it reads `~/.bashrc` and not
1071 `~/.profile`. That's why the installer puts its PATH block in `~/.bashrc` (§2).
1072
1073 You may notice small dots and a faint label (e.g. `other · drift`) drifting
1074 across empty space after a turn. That's Codewhale's decorative "ambient life"
1075 whale, not a rendering bug.
1076
1077 ### Other terminals
1078
1079 tmux eats **F1**, so use `/help` there. Some key chords (Ctrl-Shift-…, Ctrl-Tab)
1080 need a terminal with an enhanced keyboard protocol; [KEYBINDINGS.md](KEYBINDINGS.md) lists
1081 portable alternatives. Windows users should use Windows Terminal
1082 **(untested on this VM)**.
1083
1084 ---
1085
1086 ## 12. Uninstalling
1087
1088 ### Step 1: forget stored keys (if you used `auth set` or F3)
1089
1090 ```bash
1091 codewhale auth clear --provider deepseek
1092 ```
1093
1094 ### Step 2: remove the program
1095
1096 The `uninstall` command exists in Codewhale 0.10.3 and later. On 0.10.2 or earlier it is not a command, and typing it starts a chat that sends the word to your model. Remove the files by hand instead, for a Unix installer copy: `rm <dir>/codewhale <dir>/codew <dir>/.codewhale-install.sha256`, where `<dir>` is the install directory (`~/.local/bin` by default).
1097
1098 | Installed with | Remove with |
1099 |---|---|
1100 | current Unix installer (§2) | Run the intended executable by its full path with `uninstall` to inspect the plan, then `uninstall --yes` to remove it. |
1101 | Windows release archive (`install.ps1`) | `"%USERPROFILE%\bin\codewhale.exe" uninstall`, then `uninstall --yes`. Remove `%USERPROFILE%\bin` from your user PATH; `install.ps1` adds it by default (see below). |
1102 | Windows setup (NSIS) | Settings > Apps > CodeWhale > Uninstall, or `%LOCALAPPDATA%\Programs\CodeWhale\Uninstall.exe`. `codewhale uninstall` prints this path. |
1103 | WinGet | `winget uninstall --id HunterBown.CodeWhale` |
1104 | Scoop | `scoop uninstall codewhale` |
1105 | older `curl \| sh` install without a receipt | `~/.local/bin/codewhale uninstall --yes`: in a known older curl-installer directory (`~/.local/bin`, `~/.local/codewhale/bin`, `~/.local/codewhale-release.*`, or `%USERPROFILE%\bin` on Windows) it records a receipt for the commands whose bytes match the running program, then removes only those. A symlink, a hard link, or a file you do not own among them stops it before any receipt is written. |
1106 | manual copy elsewhere (§3) | Inspect the exact command paths and provenance before removing them manually; automatic uninstall preserves them. |
1107 | npm | `npm uninstall -g codewhale` (`codewhale uninstall` prints the `--prefix` for this copy) |
1108 | Cargo | `cargo uninstall codewhale-cli` (`codewhale uninstall` prints the owning `--root`) |
1109 | Homebrew | `brew uninstall codewhale` (`codewhale uninstall` prints the owning formula; untap only when you no longer use the tap) |
1110
1111 Not sure which one you have? Run `codewhale doctor --installs`: it lists every copy, who owns it and the exact command that removes it, without running or changing anything. `codewhale uninstall` (no `--yes`) shows the same classified list after its own plan.
1112
1113 The Unix installers and the Windows archive installer write `.codewhale-install.sha256` beside the commands. Uninstall accepts only existing regular files whose bytes match that receipt and, on Unix, whose hard links all belong to the receipted commands in that directory (non-command files, the receipt itself, legacy unreceipted installs, and Windows binaries must remain single-link). On Unix, receipts, selected files and their retained parent directory must belong to the current user and must not be writable by group or others. Optional compiled-host files use their existing release receipt. All selected files pass preflight before any removal; the executing command is removed last. Modified files, symlinks, external hard links, ambiguous receipts, shared writable directories, legacy unreceipted installs and unrelated files are preserved. No recursive directory removal is performed. A failed removal reports which entries were unlinked, any remaining recovery paths, and any durability failure. If the command receipt was unlinked while the executable remains, recovery republishes it only to a vacant receipt name.
1114
1115 The command runs before configuration, credential migration and telemetry, so malformed config does not block it. It preserves data, credentials, workspaces and services. For a receipted release copy it also removes this install's exact three-line `# >>> codewhale PATH >>>` block from your shell profiles, and the Codewhale-generated completion files at the documented paths (`~/.local/share/bash-completion/completions/codewhale`, `~/.zfunc/_codewhale`, `~/.config/fish/completions/codewhale.fish`, honouring `XDG_DATA_HOME` and `XDG_CONFIG_HOME`). Nothing else in a profile is touched, a symlinked or unreadable profile is left for you to edit by hand, and the completion files are kept while another Codewhale copy remains on PATH. If any of that cleanup fails, the command says so and exits non-zero even though the program is already gone. Package-managed copies get removal guidance; custom Cargo roots with local Cargo metadata are recognized. Other command copies still on PATH are listed without running them. Refresh the shell command cache with `hash -r` and inspect the remaining entries.
1116
1117 Successful self-update renews an existing command receipt, and writes one for a pre-receipt directory whose commands it just installed; it never claims unknown siblings. This command does not remove a remote-setup service or a desktop application.
1118
1119 On Windows, `codewhale uninstall --yes` removes `codewhale.exe`, `codew.exe`, `codewhale.bat`, any receipted compiled-host files and the receipt itself. Windows cannot delete a running program, so the running `codewhale.exe` is renamed in place to a `.codewhale-host-recovery-…` name and deleted by a helper once the command exits; the output names that file in case it remains. `codewhale.old-…` files left by an earlier self-update are listed, not deleted. A known legacy directory can adopt matching command bytes into a receipt. Other unreceipted archive copies are preserved; reinstall with the current `install.ps1` to obtain a receipt before automatic removal. Windows removal has been compile-checked but not yet exercised on a Windows host.
1120
1121 The Windows archive's `install.ps1` adds `%USERPROFILE%\bin` to your **user** PATH by default (one registry value, `HKCU\Environment\Path`; it never touches the machine PATH), prints what it added and the PowerShell command that removes just that entry, and does nothing when the directory is already on PATH. Run it with `-NoModifyPath` (or `CODEWHALE_NO_MODIFY_PATH=1`) to skip the edit, and `install.bat -NoModifyPath` passes the flag through; it then prints the command to add the entry yourself. Running it again never adds a second entry. Windows terminals that are already open do not see the change, so its last lines give the command for the current window and `codewhale --version`. (Archives older than 0.10.3 do not modify PATH and tell you to add the directory yourself.) This path has not been run on a Windows host.
1122
1123 Repeating `uninstall` after removal is safe: the removed copy is gone, and any other copy only removes what its own receipt owns. Reinstalling into the same directory afterwards writes a fresh receipt.
1124
1125 ### Step 3: remove data. Program removal keeps it by default.
1126
1127 `codewhale uninstall --purge-data` previews the data removal. Without an explicit
1128 `CODEWHALE_HOME`, the targets are `~/.codewhale` and the legacy
1129 `~/.deepseek/snapshots`. With an explicit `CODEWHALE_HOME`, only that directory
1130 is considered; the legacy snapshots are preserved. A custom target must be named
1131 `.codewhale` to qualify for automatic purge.
1132
1133 The purge requires a successful receipted program removal in the same `--yes`
1134 run. A package-managed copy, preview or failed removal keeps the data. All targets
1135 are checked before program removal: symlinks, another user's directory, your home
1136 or its ancestors, and any target containing the installation are refused.
1137 Sessions, workspace snapshots and recovery copies in those targets are deleted
1138 by the purge; review the preview and preserve anything needed before confirming.
1139
1140 | Retained item | How to review it |
1141 |---|---|
1142 | OS keyring entries | Run `codewhale auth clear --provider <id>` before removing the program. |
1143 | Per-workspace `.codewhale` directories | Inspect the known workspace individually; uninstall does not search or remove them. |
1144 | A bare `export PATH=…` line you added yourself, and completion files outside the documented paths | Yours to review: uninstall only removes the marked block and the documented Codewhale-generated completion files. |
1145 | Other installed command copies | Use `codewhale doctor --installs`; each copy follows its own owner and receipt. |
1146 | Legacy snapshots with explicit `CODEWHALE_HOME` | Review them separately; explicit-home purge does not include them. |
1147
1148 A reinstall restores the program, not purged sessions or snapshots. Installation,
1149 remote services and desktop applications have separate ownership; this command
1150 only removes what its selected command installation owns.
1151
1152 ---
1153
1154 ## 13. Troubleshooting
1155
1156 Every error below was hit while writing this guide.
1157
1158 **`bash: codewhale: command not found` right after installing.**
1159 `~/.local/bin` isn't on PATH in this terminal. See
1160 [Put it on your PATH](#put-it-on-your-path).
1161
1162 **`npm error code EACCES … permission denied, mkdir '…/lib/node_modules/codewhale'`.**
1163 Your Node is system-owned. See [§4](#if-you-get-eacces-permission-denied).
1164 Don't use sudo.
1165
1166 **`error: DeepSeek API key not found.` (from `codewhale exec`)**
1167 No key anywhere. Follow the printed steps, or see §8.
1168
1169 **The TUI shows your message but never answers.**
1170 No key (v0.10.0 doesn't say so). Press F3 → DeepSeek → Enter → paste the key.
1171
1172 **`error: Responses API request failed … Authentication Fails, Your api key: ****dead is invalid`.**
1173 The key is wrong or revoked. Run `codewhale auth status --provider deepseek`
1174 to see *which* source is being used. Remember that config and the secret store
1175 beat the env var. Fix with `codewhale auth set --provider deepseek`, or
1176 `codewhale auth clear --provider deepseek` to fall back to the env var. In the
1177 TUI, a bad key sends you to a "Choose your model provider" screen that marks
1178 DeepSeek `last check failed (authentication)`.
1179
1180 **`error: Network error: SSE stream request failed after HTTP/1.1 fallback: Responses API request failed. … on Windows or proxy networks, try CODEWHALE_FORCE_HTTP1=1 …`.**
1181 Despite the wording, on Linux this usually just means **no connection to
1182 `api.deepseek.com`**. Check with `curl -sI https://api.deepseek.com` (a `401`
1183 response is fine; it means the host is reachable). If you're behind a proxy,
1184 make sure `HTTPS_PROXY` is exported. `codewhale doctor --probe-api` only says
1185 `✗ API connection failed` for both bad keys and network problems.
1186
1187 ### A local proxy that closed after the session started
1188
1189 reqwest reads `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY` when a client is
1190 built, and a session builds its clients once. Without a fallback, a local proxy
1191 (Clash, v2rayN, sing-box) that stops after Codewhale starts leaves every
1192 request dialing a port that no longer answers — including requests to providers
1193 that need no proxy at all.
1194
1195 Codewhale now watches that port on the paths listed below. While it refuses
1196 connections, requests on those paths go direct; when it answers again, proxy
1197 routing resumes. Detection runs in the background and takes effect within a few
1198 seconds of a port starting to refuse, so a request issued in that gap can still
1199 fail once. A port that drops packets instead of refusing them is not treated as
1200 down at all.
1201
1202 Paths that install the watch: the model client and the API-key verification
1203 probe, the model-list and catalog clients, HTTP/1.1 fallback, web search, web
1204 run, vision, the MCP registry, `models.dev`, the profile constitution
1205 check, the TUI balance poll and the remote-control relay. `doctor --probe-api`
1206 and `doctor --probe-local` go through the model client, so they are covered.
1207
1208 Other probes keep the previous behaviour and can still fail while a local proxy
1209 is down: `doctor`'s search probe and the Runtime API runtime-info probe read
1210 the proxy environment themselves, `cloud-facts` refreshes the same way, and the
1211 sandbox client is not covered. The dev-server readiness probe is not affected at
1212 all because it always goes direct.
1213
1214 Only loopback proxies are watched, each on its own port: a live `HTTP_PROXY`
1215 does not keep a dead `HTTPS_PROXY` in the path, and a remote proxy in the same
1216 configuration is routed through exactly as before, never diverted. While a port
1217 answers, `NO_PROXY`, proxy credentials and the `ALL_PROXY` / `HTTP_PROXY` /
1218 `HTTPS_PROXY` precedence are unchanged. Detection is a TCP probe rather than a
1219 proxy handshake, so a process that holds the port without forwarding traffic
1220 still counts as up.
1221
1222 The proxy environment is read once, when the first client is built. Exporting a
1223 different `HTTPS_PROXY` mid-session needs a restart.
1224
1225 Going direct means the connection leaves from your own address. If you rely on
1226 the proxy to hide it, set the variable below instead of letting the fallback
1227 run; `NO_PROXY` matches still go direct either way.
1228
1229 Set `CODEWHALE_LOCAL_PROXY_FALLBACK=0` to keep the previous behaviour.
1230
1231 **`codewhale install: refusing to replace existing ~/.local/bin/codewhale`.**
1232 A different version is already installed there. Run `codewhale update`, or
1233 delete the two files first (§7 rollback), or install into a fresh
1234 `CODEWHALE_INSTALL_DIR`.
1235
1236 **`codewhale install: checksum mismatch for codew-linux-x64`.**
1237 The download was corrupted or tampered with. Nothing was installed. Retry, and
1238 if it repeats, don't use a mirror.
1239
1240 **`Not updated: use the command above.` (from `codewhale update`)**
1241 You installed with npm, Cargo or Homebrew. Run the command printed above that
1242 line; `codewhale update` exits 1 so scripts can tell nothing was updated.
1243 `codewhale uninstall` ends the same way (`Not removed: use the command above.`).
1244
1245 **`error: failed to run custom build command for libdbus-sys` (Cargo).**
1246 Run `sudo apt-get install -y libdbus-1-dev pkg-config`.
1247
1248 **`error: No saved sessions found for workspace …` (from `exec --continue`).**
1249 No session has been saved in this workspace. Fresh answer-only text and `--json`
1250 exec runs are saved only if conversation compaction starts; use
1251 `--output-format stream-json` to always save them.
1252 TUI sessions and exec runs that offer tools are saved in every output format.
1253
1254 **zsh completion suggests the wrong things after the first word.**
1255 Known v0.10.0 bug. bash and fish are fine.
1256
1257 **Getting help:** `codewhale doctor --json` produces a diagnostics bundle
1258 without secrets.
1259
1260 ---
1261
1262 ## Appendix: other platforms (not re-tested in this revision)
1263
1264 The sections below are carried over unchanged from the previous revision of
1265 this page. They were **not re-run** for the v0.10.0 install test above
1266 (out of scope: Windows, macOS, Android/Termux, FreeBSD, mainland-China
1267 mirrors), apart from the macOS paths noted in [macOS notes](#macos-notes).
1268 Known contradictions with the published v0.10.0 assets, found by inspecting
1269 them ([details](https://github.com/codewhale-hq/Codewhale/blob/37ecdfcc49bc68a9b0d058b97c3946e62c34bd31/docs/install-report/v0.10.0-2026-09-23/DOC_DEFECTS.md), D15 and D16):
1270
1271 * v0.10.0 publishes both `codewhale-windows-x64.zip` (with an `install.bat`
1272 that copies to `%USERPROFILE%\bin`) and `codewhale-windows-x64-portable.zip`;
1273 the sections below mention only the first.
1274 * The standalone `codewhale.bat` launcher works only next to the x64 exe.
1275
1276 ### Supported platforms and assets
1277
1278 The [latest stable release](https://github.com/codewhale-hq/CodeWhale/releases/latest)
1279 publishes Linux x64/arm64, macOS x64/arm64, Windows x64/arm64, and Android arm64
1280 assets. A release that includes the OpenHarmony leg also publishes a native
1281 HarmonyOS/OpenHarmony arm64 tarball. Artifact presence is distinct from platform
1282 qualification.
1283 The table below describes the current source tree's platform and secondary
1284 packaging support; `latest` installation still selects the published release.
1285 Android/Termux is preview pending real-device QA. Linux ARM64 is available from
1286 v0.8.8 onward. Linux RISC-V prebuilts are temporarily paused because the locked
1287 `rquickjs-sys` dependency does not ship `riscv64gc-unknown-linux-gnu` bindings.
1288
1289 | Platform | Architecture | GitHub release asset | npm install | `cargo install` |
1290 | ------------ | ------------ | ----------------------------------------------------- | :---------: | :-------------: |
1291 | Linux | x64 (x86_64) | `codewhale-linux-x64`, `codew-linux-x64` | ✅ | ✅ |
1292 | Linux | arm64 | `codewhale-linux-arm64`, `codew-linux-arm64` | ✅ | ✅ |
1293 | Android / Termux | arm64 (aarch64) | `codewhale-android-arm64.tar.gz` (published in v0.9.12; device support is preview) | ⚠️⁴ preview | ⚠️⁴ preview |
1294 | HarmonyOS / OpenHarmony (native) | arm64 (aarch64) | `codewhale-ohos-arm64.tar.gz` (self-signed inside; only in releases that list it), otherwise build and sign — see [HarmonyOS](HarmonyOS.md) | ❌ | ❌ |
1295 | Linux | riscv64 | temporarily unsupported until upstream bindings land | ❌¹ | ❌³ |
1296 | macOS | x64 | `codewhale-macos-x64`, `codew-macos-x64` | ✅ | ✅ |
1297 | macOS | arm64 (M-series) | `codewhale-macos-arm64`, `codew-macos-arm64` | ✅ | ✅ |
1298 | Windows | x64 | `codewhale-windows-x64.exe`, `codew-windows-x64.exe` | ✅ | ✅ |
1299 | Windows | arm64 | `codewhale-windows-arm64.exe`, `codew-windows-arm64.exe` | ✅ | ✅ |
1300 | Linux x64 or arm64 on musl (Alpine) | native arch | matching static Linux asset | ✅ (static) | ✅ |
1301 | Other Linux (musl on other arches) | — | build from source | ❌¹ | ✅² |
1302 | FreeBSD 14+ | x64, arm64 | `cargo install codewhale-cli --locked` (no prebuilt; see § FreeBSD) | ❌ | ✅² |
1303
1304 ¹ The npm package will exit with a clear error and point you here.
1305 ² Provided your toolchain can compile a recent Rust workspace; see
1306 [Build from source](#5-cargo-and-building-from-source) below.
1307 ³ RISC-V source builds currently need upstream `rquickjs-sys` RISC-V bindings or
1308 a bindgen-enabled dependency build.
1309 ⁴ The current npm wrapper recognizes Android arm64 and resolves
1310 the matching `codewhale` and `codew` Android assets. npm
1311 installation works only for a package version whose GitHub Release publishes
1312 those matching assets. The Android/Termux path remains preview-only until the
1313 real-device compile, startup, approval, file-tool, and update checks tracked
1314 in #4236 and #4242 are complete.
1315
1316 Android / Termux is not the same target as Linux arm64. Do not install the
1317 Linux `codewhale-linux-arm64` archive in Termux; use the Termux-specific
1318 Android archive when a release or release candidate publishes one, or build
1319 from source inside Termux.
1320
1321 The HarmonyOS row is the native target only. Inside the Linux subsystem
1322 (融合开发引擎, an openEuler virtual machine) the ordinary Linux ARM64 asset works.
1323
1324 The current Linux **x64 and arm64** assets are **static musl builds**.
1325 Both the x64 and arm64 release paths use static musl linking and pass
1326 static-launch checks. These binaries have no glibc dependency and
1327 run on their matching architecture across Ubuntu, Debian, RHEL/CentOS, and
1328 Alpine/musl. SQLite is bundled through `rusqlite`, so no separate `libsqlite3`
1329 runtime package is needed.
1330
1331 #### Linux ARM64 portability
1332
1333 Linux arm64 assets before v0.9.6 were GNU libc builds and could inherit the
1334 Ubuntu 24.04 build host's `GLIBC_2.39` floor. Ubuntu 22.04 ships glibc 2.35, so
1335 those older arm64 binaries can fail with errors such as:
1336
1337 ```text
1338 version `GLIBC_2.39' not found
1339 ```
1340
1341 The npm wrapper, `codewhale update`, and the Unix archive installer retain their
1342 GNU-binary preflight for older releases. The current arm64 build instead uses
1343 `aarch64-unknown-linux-musl`, so it has no `GLIBC_*` floor. If you are installing
1344 an earlier release on an older arm64 distribution, use:
1345
1346 ```bash
1347 cargo install codewhale-cli --locked # installs `codewhale`
1348 ```
1349
1350 > **Linux ARM64 note (v0.8.7 and earlier).** v0.8.7 and earlier do **not**
1351 > publish a Linux ARM64 prebuilt; users on HarmonyOS thin-and-light, Asahi
1352 > Linux, Raspberry Pi, AWS Graviton, etc. saw `Unsupported architecture: arm64`
1353 > from `npm i -g codewhale`. v0.8.8 publishes `codewhale-linux-arm64`, so a plain `npm i -g codewhale` works
1354 > on any glibc-based ARM64 Linux. If you're stuck on v0.8.7, jump to
1355 > [Build from source](#5-cargo-and-building-from-source) — `cargo install` works fine.
1356 > For HarmonyOS PC and OpenHarmony cross-build setup, see
1357 > [HarmonyOS and OpenHarmony](HarmonyOS.md).
1358
1359 ### Migrating from npm, Cargo, or another installation
1360
1361 Package managers continue to own their files. `codewhale update` gives migration
1362 instructions for npm, Cargo, Homebrew, and Omarchy instead of overwriting them.
1363 Known system/package directories are also protected. A `CODEWHALE_INSTALL_METHOD=binary`
1364 override cannot bypass a recognized managed path.
1365
1366 Re-running the installer upgrades an earlier Codewhale in `~/.local/bin` in
1367 place (old files go to the recovery folder). Create a fresh destination only
1368 when you want to keep every existing installation exactly as it is:
1369
1370 ```bash
1371 mkdir -p "$HOME/.local"
1372 codewhale_install_dir="$(mktemp -d "$HOME/.local/codewhale-release.XXXXXX")"
1373 curl -fsSL https://codewhale.net/install.sh | CODEWHALE_INSTALL_DIR="$codewhale_install_dir" sh -s -- --no-modify-path
1374 "$codewhale_install_dir/codewhale" --version
1375 export PATH="$codewhale_install_dir:$PATH"
1376 hash -r
1377 command -v codewhale codew
1378 "$codewhale_install_dir/codewhale" update --check
1379 ```
1380
1381 `--no-modify-path` keeps the installer from touching your profile for a side-by-side
1382 copy. After verifying the version and command paths, keep that directory first in your
1383 shell profile. In PowerShell, use `Get-Command codewhale, codew -All` to inspect
1384 resolution; run the selected executable using its full path. A successful update
1385 only changes its own install directory, so another earlier PATH entry can still
1386 launch an older copy.
1387
1388 Modern matched `codewhale`, `codew`, and compatibility copies update from the
1389 same verified bytes. Symlinks to the running binary are preserved. A sibling
1390 that is a different Codewhale build is moved to the recovery folder and
1391 replaced; an unrelated sibling is named in the error and left untouched. No
1392 sibling is executed merely to guess its owner.
1393
1394 To retain a secondary package-managed install, use its manager:
1395
1396 ```bash
1397 npm install -g codewhale@latest
1398 # or
1399 cargo install codewhale-cli --locked --force
1400 ```
1401
1402 Homebrew uses `brew upgrade codewhale`; Omarchy uses `omarchy update`. These
1403 commands update their own copies, so verify PATH again afterward.
1404
1405 <a id="android--termux-arm64"></a>
1406
1407 ### Android / Termux arm64 (preview)
1408
1409 Termux runs on Android's Bionic libc and uses `$PREFIX` as its Unix prefix, so
1410 it needs a Termux-specific Android arm64 archive. The Linux arm64 release asset
1411 targets standard Linux with musl; Android uses a distinct Rust target, so the
1412 Linux asset should not be used there.
1413
1414 Install the minimum archive/runtime tools first:
1415
1416 ```bash
1417 pkg update
1418 pkg install -y ca-certificates curl tar gzip coreutils
1419 ```
1420
1421 When the release includes `codewhale-android-arm64.tar.gz`, install it with the
1422 archive's bundled installer. Passing `PREFIX="$PREFIX"` matters: the installer
1423 defaults to `~/.local`, while Termux users normally expect commands under
1424 `$PREFIX/bin`.
1425
1426 ```bash
1427 cd "$HOME"
1428 curl -L -O https://github.com/codewhale-hq/CodeWhale/releases/latest/download/codewhale-android-arm64.tar.gz
1429 curl -L -O https://github.com/codewhale-hq/CodeWhale/releases/latest/download/codewhale-bundles-sha256.txt
1430 sha256sum -c codewhale-bundles-sha256.txt --ignore-missing
1431
1432 tar xzf codewhale-android-arm64.tar.gz
1433 cd codewhale-android-arm64
1434 PREFIX="$PREFIX" ./install.sh
1435 hash -r
1436 ```
1437
1438 If you are validating from source or building a release candidate locally,
1439 install the build packages before running Cargo:
1440
1441 ```bash
1442 pkg install -y rust clang pkg-config make git
1443 cargo install codewhale-cli --locked # installs `codewhale`
1444 ```
1445
1446 The normal first-run setup path is implemented, but its Android interaction is
1447 still part of the preview QA above. Prefer provider environment variables for
1448 temporary credentials. `codewhale auth set` is available, but the Termux build
1449 has no supported OS keyring integration and falls back to file-backed secrets
1450 by writing `~/.codewhale/config.toml` and mirroring keys to
1451 `~/.codewhale/secrets/secrets.json`. Both are plaintext files protected by
1452 `0600` permissions and are not encrypted at rest.
1453
1454 ```bash
1455 codewhale auth set --provider deepseek
1456 codewhale auth status
1457 codewhale doctor
1458 ```
1459
1460 Maintainers should use this repeatable smoke checklist for a Termux / Android
1461 arm64 release candidate:
1462
1463 ```bash
1464 command -v codewhale codew
1465 test -x "$PREFIX/bin/codewhale"
1466 test -x "$PREFIX/bin/codew"
1467
1468 codewhale --version
1469 codewhale doctor
1470 codewhale exec --auto "run pwd"
1471 ```
1472
1473 Known limitations:
1474
1475 - Commands inherit Android's per-app UID, SELinux, and seccomp protections and
1476 any permissions granted to Termux. Codewhale's bubblewrap
1477 child-process sandbox is Linux-only and is not built on Android, so approved
1478 commands receive no Codewhale-specific filesystem narrowing.
1479 - The Termux build has no supported Android Keystore or desktop Secret Service
1480 integration. Use `codewhale auth status` to confirm the active source and
1481 prefer provider environment variables when file-backed plaintext storage is
1482 not acceptable.
1483 - Terminal rendering varies by Android terminal app. The TUI always owns the
1484 alternate screen. If a terminal app cannot render the full-screen TUI,
1485 use `codewhale exec` for headless runs instead.
1486
1487 ### China / mirror-friendly install
1488
1489 When installing from mainland China, configure mirrors for both **rustup**
1490 (the Rust toolchain installer) and **Cargo** (the package registry) to avoid
1491 TLS timeouts and download failures.
1492
1493 **Step 1: Install Rust via a rustup mirror**
1494
1495 ```bash
1496 # PowerShell
1497 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
1498 (New-Object Net.WebClient).DownloadFile('https://win.rustup.rs/x86_64', 'rustup-init.exe')
1499
1500 # git-bash / msys2
1501 export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
1502 export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
1503 ./rustup-init.exe -y --default-toolchain stable
1504
1505 # Linux / macOS
1506 export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
1507 export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
1508 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
1509 ```
1510
1511 If the TUNA mirror is slow from your network, `rsproxy.cn` is another
1512 rustup mirror option for Linux/macOS:
1513
1514 ```bash
1515 export RUSTUP_DIST_SERVER=https://rsproxy.cn
1516 export RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup
1517 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
1518 ```
1519
1520 The `RUSTUP_DIST_SERVER` and `RUSTUP_UPDATE_ROOT` environment variables must
1521 be set **before** running rustup-init; the toolchain download otherwise hits
1522 the same TLS handshake problem as the installer.
1523
1524 **Step 2: Configure Cargo registry mirror**
1525
1526 ```toml
1527 # ~/.cargo/config.toml
1528 [source.crates-io]
1529 replace-with = "tuna"
1530
1531 [source.tuna]
1532 registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
1533 ```
1534
1535 `rsproxy`, Tencent COS, and Aliyun OSS mirrors work the same way; pick whichever
1536 is fastest from your network.
1537
1538 ### Omarchy / AUR
1539
1540 On Omarchy, install the prebuilt AUR package:
1541
1542 ```bash
1543 omarchy pkg aur add codewhale-bin
1544 codewhale --version
1545 ```
1546
1547 `codewhale-bin` packages the same checksum-pinned Linux release archives as the
1548 other binary install paths and provides both `codewhale` and `codew`. It does
1549 not carry a separate Codewhale version; the existing `codewhale-tui`
1550 compatibility command remains an alias to the same runtime. Package updates
1551 arrive through `omarchy update`; the in-app updater leaves the pacman-owned
1552 binary to Omarchy.
1553
1554 The AUR update follows the matching Codewhale tag and release assets, so it may
1555 appear after the GitHub release while its generated `PKGBUILD` and `.SRCINFO`
1556 are validated. Release-maintainer instructions live in
1557 [`packaging/aur/README.md`](../packaging/aur/README.md).
1558
1559 ---
1560
1561 ### Windows
1562
1563 #### Windows Scoop
1564
1565 The `codewhale` package is listed in Scoop's main bucket:
1566
1567 ```powershell
1568 scoop update
1569 scoop install codewhale
1570 codewhale --version
1571 ```
1572
1573 Scoop manifests are maintained outside this repository's release workflow and
1574 can lag GitHub/npm/Cargo releases. Use npm or manual GitHub release downloads
1575 when you need the newest version immediately.
1576
1577 #### Windows winget
1578
1579 WinGet installs **`HunterBown.CodeWhale`** as the portable x64 command
1580 `codewhale`. It downloads `codewhale-tui-windows-x64.exe` and declares a
1581 dependency on the Microsoft Visual C++ 2015+ x64 runtime.
1582 [Published manifests](https://github.com/microsoft/winget-pkgs/tree/master/manifests/h/HunterBown/CodeWhale)
1583
1584 ```powershell
1585 winget install HunterBown.CodeWhale
1586 codewhale --version
1587 ```
1588
1589 Update with `winget upgrade --id HunterBown.CodeWhale`. Each
1590 version goes through winget-pkgs review after the GitHub Release, so winget can
1591 lag GitHub/npm/Cargo; use npm or the GitHub Release asset when you need the
1592 newest version immediately.
1593
1594 Known limits of the winget route:
1595
1596 * **x64 only.** The published manifest has no ARM64 installer. On Windows ARM64,
1597 use `npm install -g codewhale` under native ARM64 Node.js, or download
1598 `codewhale-windows-arm64.zip` from GitHub Releases.
1599 * **`codewhale` only.** The short `codew` alias is not installed by winget; use
1600 `codewhale`.
1601 * The release generator prepares a matching local manifest. [WinGet packaging](../packaging/winget/README.md).
1602
1603 #### Windows NSIS Installer
1604
1605 For the OS/terminal compatibility targets and current evidence, see
1606 [Windows support and release qualification](ENVIRONMENTS.md#windows-support-and-release-qualification).
1607
1608 A standalone NSIS-based installer is available for
1609 Windows users who prefer a traditional double-click setup (no npm, no Scoop, no
1610 Cargo required).
1611
1612 The NSIS installer currently contains the Windows x64 binaries. Windows ARM64
1613 users should install through npm running under native ARM64 Node.js or download
1614 `codewhale-windows-arm64.zip` from the same release; both paths then use native
1615 ARM64 binaries.
1616
1617 **Download** `CodeWhaleSetup.exe` from the
1618 [Releases page](https://github.com/codewhale-hq/CodeWhale/releases/latest).
1619
1620 **Install** by double-clicking the setup executable. The installer:
1621
1622 - Installs `codewhale.exe` and `codew.exe` side-by-side (single binary, no `codewhale-tui.exe`) into
1623 `%LOCALAPPDATA%\Programs\CodeWhale\bin`
1624 - Installs `codewhale.bat`, which prefers Windows Terminal (`wt.exe`) when it is on `PATH` and
1625 otherwise launches the exe directly
1626 - Creates a current-user Start Menu shortcut that opens that launcher, not the raw `.exe`
1627 - Adds the install directory to the **current user** `PATH`
1628 - Registers in Windows **Apps & Features** for easy uninstall
1629
1630 Uninstall removes the binaries, `codewhale.bat`, the Start Menu shortcut, and the user `PATH` entry.
1631
1632 **Silent install** (for IT admins, SCCM, Intune):
1633
1634 ```powershell
1635 CodeWhaleSetup.exe /S
1636 ```
1637
1638 The installer is per-user and does not request elevation. Run silent installs in
1639 the target user's context, or use a deployment tool that can run the installer
1640 for each user profile that needs Codewhale.
1641
1642 The release-built installer is currently unsigned and may trigger Windows
1643 SmartScreen. Verify the SHA-256 checksum from `codewhale-artifacts-sha256.txt`
1644 before deploying, and sign the installer in your internal deployment pipeline if
1645 your environment requires signed application packages.
1646
1647 **Build the installer yourself** (requires [NSIS](https://nsis.sourceforge.io)):
1648
1649 ```powershell
1650 cd scripts\installer
1651 # Place codewhale.exe and codew.exe here (single binary, no codewhale-tui.exe), then:
1652 makensis /DVERSION=<version> codewhale.nsi
1653 ```
1654
1655 **Manual fallback** — if the installer is blocked by group policy, see the
1656 [CLASSROOM_INSTALL.md](CLASSROOM_INSTALL.md) guide for step-by-step PowerShell
1657 commands.
1658
1659 > **Deploying to a classroom or lab?** See the full
1660 > [Classroom Install Checklist](CLASSROOM_INSTALL.md) for silent install,
1661 > API key provisioning, imaging notes, and troubleshooting.
1662
1663 <a id="freebsd"></a>
1664
1665 ### FreeBSD, cross-compiling, Windows source builds
1666
1667 #### FreeBSD 14+ source-build workaround (#1097)
1668
1669 FreeBSD has no prebuilt GitHub Release asset — `npm install -g codewhale` intentionally
1670 fails with `Unsupported platform: freebsd` and points to Cargo. Install from source:
1671
1672 ```bash
1673 pkg install -y rust pkgconf git
1674 cargo install codewhale-cli --locked # installs `codewhale`
1675 codewhale --version
1676 codewhale doctor
1677 ```
1678
1679 The `rquickjs` FreeBSD bindings are generated at build time via `bindgen` (see
1680 `1582ba965`/`5eb0385e8`). No separate `pkg install codewhale` port exists yet —
1681 a native port is tracked as the follow-up to #1097 under `packaging/freebsd/`
1682 (contributions welcome). Validate with `cargo check --target x86_64-unknown-freebsd -p codewhale-cli --locked`
1683 on the release branch; the 8×1 release matrix (Linux musl x64/arm64,
1684 Android arm64, macOS x64/arm64, Windows x64/arm64, OpenHarmony arm64) stays 8 targets — FreeBSD is a
1685 source-build target, not a prebuilt asset.
1686
1687 #### Cross-compiling from x64 to ARM64 Linux
1688
1689 The release asset uses `aarch64-unknown-linux-musl` and is built on a native ARM
1690 runner. If you want to build a GNU-linked ARM64 Linux binary on an x64 Linux
1691 host (e.g. for the openEuler Linux subsystem on a HarmonyOS PC), use
1692 [`cross`](https://github.com/cross-rs/cross), which wraps the official Rust
1693 cross-targets in a Docker container:
1694
1695 ```bash
1696 # Once
1697 rustup target add aarch64-unknown-linux-gnu
1698 cargo install cross --locked
1699
1700 # Per build
1701 cross build --release --target aarch64-unknown-linux-gnu -p codewhale-cli # single binary
1702 ```
1703
1704 The resulting binary lands in
1705 `target/aarch64-unknown-linux-gnu/release/codewhale`. Copy it to the ARM64 host
1706 (e.g. via `scp`) and make it executable. This local GNU build is distinct from
1707 the portable musl release asset; either executable can be copied under the
1708 `codew` convenience name.
1709
1710 If you don't have Docker available, install the cross-linker directly and let
1711 Cargo do the work:
1712
1713 ```bash
1714 sudo apt-get install -y gcc-aarch64-linux-gnu
1715 rustup target add aarch64-unknown-linux-gnu
1716
1717 cat >> ~/.cargo/config.toml <<'EOF'
1718 [target.aarch64-unknown-linux-gnu]
1719 linker = "aarch64-linux-gnu-gcc"
1720 EOF
1721
1722 cargo build --release --target aarch64-unknown-linux-gnu -p codewhale-cli # single binary
1723 ```
1724
1725 Producing `aarch64-unknown-linux-musl` while cross-compiling requires an
1726 appropriate musl cross-linker. The release workflow avoids that extra moving
1727 part by building and launching the musl binary on GitHub's native ARM runner.
1728
1729 #### Windows build from source
1730
1731 Building on Windows requires the **MSVC C toolchain** from
1732 [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
1733 (the free workload-selectable installer, not the full IDE).
1734
1735 **Prerequisites (Windows)**
1736
1737 1. Install Visual Studio 2022 Build Tools — select the **"Desktop development
1738 with C++"** workload.
1739 2. Install [Rust](https://rustup.rs) 1.89+ (see the
1740 [China mirror instructions](#china--mirror-friendly-install) above if
1741 downloading from mainland China).
1742 3. Install [Git for Windows](https://git-scm.com/download/win) (provides `git`
1743 and the `git-bash` terminal).
1744
1745 **Recommended terminals**: Windows Terminal, `git-bash`, or PowerShell.
1746 `cmd.exe` works but has a small buffer and limited PATH behavior.
1747
1748 **Setting up the MSVC environment**
1749
1750 Visual Studio Build Tools install `cl.exe` to a versioned directory but do
1751 **not** add it to `PATH` globally. You must set the environment manually or
1752 use a Developer Command Prompt. The required variables are:
1753
1754 ```powershell
1755 # Adjust version numbers to match your installation
1756 $msvc = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207"
1757 $sdk = "C:\Program Files (x86)\Windows Kits\10"
1758 $sdkv = "10.0.26100.0"
1759
1760 $env:INCLUDE = "$msvc\include;$msvc\atlmfc\include;$sdk\Include\$sdkv\ucrt;$sdk\Include\$sdkv\um;$sdk\Include\$sdkv\shared"
1761 $env:LIB = "$msvc\lib\x64;$msvc\atlmfc\lib\x64;$sdk\Lib\$sdkv\ucrt\x64;$sdk\Lib\$sdkv\um\x64"
1762 $env:LIBPATH = "$msvc\lib\x64;$msvc\atlmfc\lib\x64"
1763 $env:CC = "$msvc\bin\Hostx64\x64\cl.exe"
1764 $env:CXX = "$msvc\bin\Hostx64\x64\cl.exe"
1765 $env:PATH = "$msvc\bin\Hostx64\x64;$env:PATH"
1766 ```
1767
1768 Alternatively, open a **"Developer Command Prompt for VS 2022"** (available
1769 from the Start Menu after installing Build Tools), which runs `vcvars64.bat`
1770 to configure all of the above automatically. Then add `cargo` to `PATH` inside
1771 that session and run `cargo build` from the project root.
1772
1773 **Cargo registry mirror** — on Windows the mirror config goes to
1774 `%USERPROFILE%\.cargo\config.toml`. See [Step 2 above](#china--mirror-friendly-install).
1775
1776 **Build**
1777
1778 ```bash
1779 git clone https://github.com/codewhale-hq/CodeWhale.git
1780 cd CodeWhale
1781 set CARGO_HTTP_CHECK_REVOKE=false # may be needed behind some Chinese ISPs
1782 cargo build --release
1783 ```
1784
1785 The Cargo-built binary appears at `target\release\codewhale.exe`. Release
1786 packaging separately exposes the same executable as `codew.exe`.
1787
1788 > Prefer not to build? Install via npm, Cargo, GitHub Releases, or the CNB
1789 > mirror — see the sections above.
1790
1791 ### Older-release and regional troubleshooting
1792
1793 #### `Unsupported architecture: arm64 on platform linux`
1794
1795 You're on a release earlier than v0.8.8 that doesn't publish Linux ARM64
1796 binaries. Use the GitHub installer in a fresh directory as described above, or use
1797 `cargo install` per [Section 4](#5-cargo-and-building-from-source).
1798
1799 #### `MISSING_COMPANION_BINARY` after upgrading an older install
1800
1801 The current single binary runs the TUI in-process and does not require a
1802 companion executable. This error identifies a stale pre-v0.9.5 dispatcher.
1803 Use the fresh-directory GitHub migration above, then verify the selected
1804 `codewhale` and `codew` paths. Do not download another separate runtime.
1805
1806 #### `codewhale update` reports `no asset found for platform codewhale-linux-aarch64`
1807
1808 Older updaters used Rust architecture names that did not match the published
1809 asset names. Use the official installer in a fresh directory as described above,
1810 then run the newly installed command by its full path.
1811
1812 #### npm download is slow or times out from mainland China
1813
1814 On Linux x64 the npm wrapper already probes GitHub Releases and the CNB
1815 first-party checksum manifests in parallel and downloads binaries only from
1816 the first source that validates. You do not need `CODEWHALE_USE_CNB_MIRROR=1`
1817 for that automatic path.
1818
1819 If both first-party sources fail, set `CODEWHALE_RELEASE_BASE_URL` to a
1820 mirrored release-asset directory (rsproxy, TUNA, Tencent COS, Aliyun OSS),
1821 or skip npm entirely and use the Cargo mirror setup in
1822 [Section 4](#5-cargo-and-building-from-source). The legacy
1823 `DEEPSEEK_TUI_RELEASE_BASE_URL` name is still accepted. `CODEWHALE_USE_CNB_MIRROR=1`
1824 still forces CNB only on Linux x64 / OpenHarmony x64.
1825
1826 #### `codewhale update` is blocked by GitHub from mainland China
1827
1828 `codewhale update` prefers GitHub Releases. On supported Linux x64 targets,
1829 a failed GitHub manifest permits the matching CNB manifest and binary fallback.
1830 If GitHub metadata is also unreachable, explicitly select a known published CNB
1831 version (`CODEWHALE_USE_CNB_MIRROR=1 CODEWHALE_VERSION=X.Y.Z codewhale update`)
1832 or a binary mirror below. Existing newer builds are kept.
1833
1834 Building from the CNB source mirror with Cargo is a secondary option. Cargo
1835 installs its own `codewhale` command:
1836
1837 To check the latest release without downloading or replacing binaries, run
1838 `codewhale update --check`.
1839
1840 ```bash
1841 cargo install --git https://cnb.cool/codewhale.net/codewhale --tag vX.Y.Z codewhale-cli --locked --force # single binary
1842 ```
1843
1844 If you operate a binary asset mirror, `codewhale update` can use it directly:
1845
1846 ```bash
1847 CODEWHALE_RELEASE_BASE_URL=https://your-mirror.example.com/CodeWhale/vX.Y.Z/ \
1848 CODEWHALE_VERSION=X.Y.Z \
1849 codewhale update
1850 ```
1851
1852 The mirror directory must contain `codewhale-artifacts-sha256.txt` and the
1853 platform binaries from the GitHub release. The legacy
1854 `DEEPSEEK_TUI_RELEASE_BASE_URL` mirror variable remains supported as an alias.
1855
1856 `codewhale update` only talks HTTPS, and only to GitHub's release hosts, the CNB
1857 mirror, and the host of the `CODEWHALE_RELEASE_BASE_URL` you set; every
1858 redirect hop is held to the same rule, so a plain-`http://` mirror is refused.
1859 A private mirror therefore works as soon as its base URL is HTTPS. If that
1860 mirror redirects asset downloads to a separate download host (a CDN or an
1861 object-store domain), name that host too:
1862
1863 ```bash
1864 CODEWHALE_UPDATE_ALLOWED_HOSTS=cdn.your-mirror.example.com,objects.example.net \
1865 CODEWHALE_RELEASE_BASE_URL=https://your-mirror.example.com/CodeWhale/vX.Y.Z/ \
1866 CODEWHALE_VERSION=X.Y.Z \
1867 codewhale update
1868 ```
1869
1870 The error message for a refused host names it and this variable.
1871
1872 ### Windows and npm-download troubleshooting
1873
1874 #### Windows: `TLS handshake eof` or `CRYPT_E_REVOCATION_OFFLINE` from `rustup-init`
1875
1876 The TLS handshake to `static.rust-lang.org` fails from behind the GFW or
1877 certain Chinese ISPs. Set the rustup mirror environment variables **before**
1878 running the installer:
1879
1880 ```bash
1881 # git-bash / msys2
1882 export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
1883 export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
1884 ./rustup-init.exe -y --default-toolchain stable
1885 ```
1886
1887 If you see `CRYPT_E_REVOCATION_OFFLINE` from Cargo after Rust is installed,
1888 also set `CARGO_HTTP_CHECK_REVOKE=false` during `cargo build`.
1889
1890 #### Windows: MSVC compiler (`cl.exe`) not found during `cargo build`
1891
1892 Visual Studio Build Tools do not add `cl.exe` to the global `PATH`. Either:
1893
1894 1. Open **"Developer Command Prompt for VS 2022"** from the Start Menu, add
1895 `%USERPROFILE%\.cargo\bin` to `PATH` in that window, and run `cargo build`
1896 from there; or
1897 2. Set the MSVC environment variables manually — see the
1898 [Windows build from source](#windows-build-from-source) section for the
1899 PowerShell snippet.
1900
1901 Verify the compiler is reachable: `cl.exe /?` should print help text.
1902
1903 #### Windows: `拒绝访问 (os error 5)` when Cargo executes build scripts
1904
1905 Third-party antivirus software (Huorong, 360, Kaspersky, etc.) may block
1906 Cargo from executing freshly-compiled build-script binaries
1907 (e.g. `libsqlite3-sys`, `aws-lc-sys`, `instability`). The error is
1908 path-agnostic — moving `target-dir` does not help.
1909
1910 **Symptoms**: `could not execute process ... build-script-build (never executed)`
1911
1912 **Workarounds** (pick one):
1913
1914 1. **Add the project's `target/` directory to your AV exclusions list.**
1915 2. **Close the antivirus software temporarily** during `cargo build`.
1916 3. **Use the GitHub Release installer/archive instead** — the release assets
1917 ship prebuilt binaries and skip the Cargo build entirely
1918 ([Section 6](#3-manual-download-from-github-releases)).
1919 4. **Use `cargo install codewhale-cli --locked`** from crates.io — this
1920 changes the binary path, which some AV tools treat differently.
1921
1922 To verify that the build-script binary itself is valid (not corrupted), locate
1923 it under `target/debug/build/<crate>/build-script-build` and run it manually:
1924
1925 ```bash
1926 target/debug/build/libsqlite3-sys-*/build-script-build
1927 # If this runs but panics with "NotPresent" (no C compiler), the binary is
1928 # fine — the AV is blocking Cargo's process-spawning path specifically.
1929 ```
1930
1931 #### npm binary download times out
1932
1933 If `codewhale` waits several seconds and prints `connect ETIMEDOUT` or
1934 `EAI_AGAIN` while fetching from `github.com`, the npm wrapper installed
1935 successfully but the prebuilt binary download is blocked or unreliable on
1936 your network. This download is separate from the npm registry package
1937 download. On Linux x64 the wrapper first races the small GitHub and CNB
1938 checksum manifests and does not wait for a full GitHub binary to time out
1939 before using a valid CNB manifest.
1940
1941 Use one of these paths:
1942
1943 1. Set a proxy and retry:
1944
1945 ```bash
1946 export HTTPS_PROXY=http://your-proxy:port
1947 codewhale
1948 ```
1949
1950 2. Mirror the release assets internally and set `CODEWHALE_RELEASE_BASE_URL`:
1951
1952 ```bash
1953 export CODEWHALE_RELEASE_BASE_URL=https://your-mirror.example.com/CodeWhale/
1954 codewhale
1955 ```
1956
1957 The directory must contain `codewhale-artifacts-sha256.txt` and the platform
1958 binaries from the GitHub release.
1959
1960 3. Install via Cargo, which builds locally and does not download GitHub release
1961 assets. See [Section 4](#5-cargo-and-building-from-source).
1962
1963 4. Download both matching `codewhale` and `codew`
1964 binaries from the [Releases page](https://github.com/codewhale-hq/CodeWhale/releases),
1965 place them in a directory on `PATH`, and make them executable. See
1966 [Section 6](#3-manual-download-from-github-releases).
1967
1967 lines MARKDOWN