Build, run, and test Hatoba locally. .github/workflows/ci.yml has the full set of checks that CI runs.
- Rust stable, Node.js 22+, and pnpm (the version is in
packageManagerin the rootpackage.json). - Windows: WebView2 (included in Windows 11).
- macOS 13 or later: the Xcode Command Line Tools (
xcode-select --install), and Rust from rustup. The Rust version that Homebrew installs may be older thanrust-versionin the rootCargo.toml, so make surerustc --versionreports the rustup toolchain. - Linux: the Tauri dependencies, such as
libwebkit2gtk-4.1-dev. The System dependencies step of therust-linuxjob inci.ymlhas the full list that CI installs. - The SSH integration tests and the end-to-end test need an OpenSSH server (
sshd).
pnpm install
pnpm tauri dev # Start the desktop app
pnpm dev # Start only the frontend, with a mock backend in the browserA release build runs one Hatoba at a time and hands the arguments of a second launch to it (HOST-13). A development build skips this, so it can run beside the installed app, unless HATOBA_SINGLE_INSTANCE is set.
In the browser, pnpm dev uses the mock backend in apps/desktop/src/ipc/mock with sample data. URL parameters switch demo states, such as ?state=locked and ?sync=conflict. The comment on createMockApi in apps/desktop/src/ipc/mock/index.ts lists most of them, and the AI mocks beside it (ai.ts, aiExtensions.ts, aiMemory.ts) list theirs.
/?gallery opens the component gallery instead of the app: every control and pattern in packages/ui (@hatoba/ui) in each state, in light, dark or side by side, at either density. Check it after changing a shared component. Only development builds include it.
Check a changed page in a browser window of the smallest window size with the AI panel open, in each language, since labels differ in length (narrow pages in §9).
pnpm tauri build --no-sign produces the NSIS installer on Windows, and the deb package and the AppImage on Linux, without the update signatures that only release builds carry.
On macOS, don't pass --no-sign: it also drops the ad-hoc code signature, and Apple Silicon Macs report an app without one as damaged once it is downloaded or copied from another Mac. Turn off the update artifacts instead, and the build produces the app bundle and the DMG:
pnpm tauri build --config '{"bundle":{"createUpdaterArtifacts":false}}'hatoba-desktop embeds the frontend build output at compile time, so build the frontend once before your first cargo command:
pnpm buildThen:
cargo test --workspace # Rust unit tests
cargo test -p hatoba-assistant # The AI assistant's tests alone, without building Tauri
pnpm typecheck && pnpm test # Frontend type check and unit tests
node --test "scripts/**/*.test.mjs" # Release and CI scripts§12 of the architecture and requirements describes what each suite covers.
These tests start a throwaway local sshd and need the OpenSSH server installed. They are skipped unless HATOBA_SSH_IT=1 is set. The test harness needs /run/sshd, the privilege separation directory of Linux OpenSSH, so run them on Linux; CI runs them only in the rust-linux job.
HATOBA_SSH_IT=1 cargo test -p hatoba-sshRun these in workers/sync:
npm install
npm run typecheck
npm test # Vitest, runs every API test on local workerd with a local D1Each test starts with an empty local D1, and the migrations are applied when the test run starts.
For manual debugging:
cp .dev.vars.example .dev.vars # Its SETUP_TOKEN is for local use only
npm run db:migrate:local
npm run dev # http://localhost:8787Local wrangler dev has no CF-Connecting-IP header, so all requests share one rate limit counter.
pnpm tauri build packages the Worker for in-app deployment with scripts/worker/bundle.mjs, and build.rs embeds the package. Other builds, such as pnpm tauri dev and cargo test, embed the package from the last run of pnpm worker:bundle, and without one the deploy commands report that the build has no Worker bundle. Run it again after changing the Worker. pnpm worker:bundle --no-install skips npm ci and uses the dependencies already installed in workers/sync.
crates/hatoba-core/tests/worker_live.rs syncs the Rust client with a real Worker running in wrangler dev, and is skipped unless HATOBA_WORKER_URL is set. The comment at the top of that file has the commands that start the Worker and run the test.
Linux only. See Run the end-to-end smoke test.
The tests in apps/desktop/src-tauri/src/update.rs run the updater against a mock endpoint and a mock list of releases. To try an update end to end on Windows without publishing a release, install a test build and serve it a newer one from this machine. The test builds have their own name, identifier, and executable, so they install next to Hatoba without touching it or its vault.
-
Generate a throwaway key outside the repository:
pnpm tauri signer generate --ci -p test -w <dir>/test.key
-
Write
<dir>/old.json, with the contents of<dir>/test.key.pubaspubkey:{ "productName": "Hatoba Update Test", "mainBinaryName": "HatobaUpdateTest", "identifier": "app.hatoba.updatetest", "version": "1.0.0", "plugins": { "updater": { "pubkey": "<contents of test.key.pub>", "endpoints": ["http://127.0.0.1:18765/latest.json"], "dangerousInsecureTransportProtocol": true } } }Write
<dir>/new.jsonwith the same contents and"version": "1.0.1". Both versions are stable ones: a prerelease version looks for updates in the GitHub releases instead of the configured endpoint. -
Build each version, and copy its installer and
.sigout oftarget/release/bundle/nsisbefore the next build:export TAURI_SIGNING_PRIVATE_KEY=<dir>/test.key TAURI_SIGNING_PRIVATE_KEY_PASSWORD=test pnpm tauri build --bundles nsis --config <dir>/old.json pnpm tauri build --bundles nsis --config <dir>/new.json
-
Run the older installer, then serve the newer one:
node scripts/release/serve-update.mjs --installer "<dir>/Hatoba Update Test_1.0.1_x64-setup.exe" --pubkey <dir>/test.key.pub
-
Open Hatoba Update Test, create a vault, and in Settings → About choose Check for Updates, then Download and Install. Hatoba closes, the installer shows its progress, and the new version opens.
-
Uninstall Hatoba Update Test in the Windows settings, delete
%LOCALAPPDATA%\app.hatoba.updatetest, and delete the throwaway key.
On Linux, build with --bundles deb,appimage and copy the packages out of target/release/bundle/deb and target/release/bundle/appimage. Install the older deb package or run the older AppImage, then pass the newer package of the same kind to serve-update.mjs, which serves it under the key that kind of build looks for in latest.json. Afterwards, remove the deb package with sudo apt remove hatoba-update-test, and delete ~/.local/share/app.hatoba.updatetest and the throwaway key.
On macOS, build each version with --bundles app and copy Hatoba Update Test.app, Hatoba Update Test.app.tar.gz, and its .sig out of target/release/bundle/macos before the next build. Copy the older app to Applications and open it, then pass the newer .app.tar.gz to serve-update.mjs. The updater replaces the app and restarts it. Afterwards, delete the app, ~/Library/Application Support/app.hatoba.updatetest, and the throwaway key.
After changing a Rust command, event, or DTO, regenerate apps/desktop/src/ipc/bindings.ts:
cargo test -p hatoba-desktop export_bindingsThe frontend has no IPC types of its own: apps/desktop/src/ipc/types.ts re-exports the bindings, and HatobaApi in apps/desktop/src/ipc/api.ts is derived from their commands. So pnpm typecheck fails wherever the frontend or the browser mock no longer matches a changed command or DTO, and the doc comments on the Rust items are what the frontend's editor shows. CI fails when the bindings are out of date.
The sync Worker has a version of its own, separate from the app version. A pull request that changes the Worker raises it (Versions in §6.7), and workerInputs in scripts/ci/worker-version.mjs lists the files, dependencies, and tsconfig.json options that count. From the repository root:
node scripts/release/bump.mjs --worker patch # Or minor, major, or an explicit version
node scripts/ci/worker-version.mjs # Compare with where the branch left origin/mainThe Sync Worker job in CI runs the same check against the base branch, and fails when the Worker changed but its version did not.
The AI assistant ships with a built-in hatoba skill in crates/hatoba-ai/src/skills/builtin/hatoba. Its SKILL.md and references/ files describe the current interface, settings, and features, so the assistant can answer questions about Hatoba, and the website publishes them as its docs. A pull request that adds, renames, or removes UI, settings, or a feature that the skill describes updates the skill in the same pull request.
- Each file stays under 15,000 characters, half of
MAX_RESULT_CHARSincrates/hatoba-ai/src/tools/results.rs, above whichread_skillshortens a file. - Name UI labels in English, copied character for character from the
enmessage tables inapps/desktop/src/i18n/locales. The other languages go in the label files, not the text. - The label files in
references/labels/give those labels in each other language, by file and##section, so the assistant can quote what the user sees. They are written fromAREASinapps/desktop/src/i18n/hatobaSkillLabels.ts, which lists the message keys of each section; only messages without a|can be listed, and a placeholder such as{host}stays in the text. To add a label, add its key there and write the files again (below). A new language gets its files fromLANGUAGE_NAMEin the same file, and each new file goes inSKILL.md's list and incrates/hatoba-ai/src/skills/builtin.rs. {{HATOBA_VERSION}}inSKILL.mdis a placeholder that the app replaces with the running version.
apps/desktop/src/i18n/hatobaSkill.test.ts runs with pnpm test. It checks the label files against the message tables, the sections they name, the frontmatter, the size limit, and the links between the files. After a label changes, write the label files again:
pnpm --filter @hatoba/desktop exec vitest run -u src/i18n/hatobaSkill.test.tsskills/hatoba-cli is the skill that coding agents install to use the hatoba command. It tells them to run hatoba --help first, so the commands, options, exit codes, and prompts are described in HELP in crates/hatoba-cli/src/args.rs, and a change to the command updates HELP, not the skill. The skill keeps a line only when the help doesn't say it and an agent would get it wrong without it, such as following a host's ai_notes, or giving a call that waits for the user a long timeout. It leaves out:
- what the help already says;
- what agents do anyway, such as asking when several hosts fit, or passing a server's message on to the user;
- general shell knowledge, such as quoting or batch flags. A Hatoba bug that agents trip over is fixed in Hatoba, not worked around in the skill.
Claude Code, Codex, and DeepSeek Harness get the skill as a plugin from hatoba-agent-plugin on npm, whose source is packaging/agent-plugin. For Claude Code and Codex it is a plugin with the manifest in .claude-plugin/plugin.json and .codex-plugin/plugin.json, which the marketplaces in the repository's .claude-plugin/marketplace.json and .agents/plugins/marketplace.json install from npm. For DeepSeek Harness it is a bundle: dsh.bundle in its package.json names cordis.patch.yml, which mounts index.mjs, a skill provider for the package's skills/, by the package's name. scripts/release/agent-plugin.mjs writes the package with skills/hatoba-cli and the release's version in each manifest, and each stable release publishes it, as Package managers describes.
The website at https://hatoba.fog.moe is an Astro site in apps/site, in English, Simplified and Traditional Chinese, and Japanese. Its text is in apps/site/src/i18n, where en.ts holds the English that the other files translate. The scripts in scripts/media make its screenshots, the README's promo film, and the repository's social preview. The Site workflow builds it for pull requests that touch it or the desktop frontend, and deploys it to GitHub Pages from main and after each release.
pnpm --filter @hatoba/site dev # http://localhost:4321
pnpm --filter @hatoba/site test
pnpm --filter @hatoba/site build # writes apps/site/dist
pnpm --filter @hatoba/site layout:check # after build: fails when a page moves while it loads (needs Chrome)The build reads the newest release from the GitHub API (set GITHUB_TOKEN if it hits the rate limit) and takes the docs from the built-in skill at that release's tag, so they describe the version people download. To preview a change to the docs, run it with HATOBA_DOCS_REF=worktree. A new reference file needs a place in DOC_GROUPS in apps/site/src/lib/docs.ts, which a test checks.
The home page's Try it in your browser button swaps its first screenshot for the app's demo at /demo/: the browser frontend and its mock backend, built with --mode demo for visitors (VISITOR in apps/desktop/src/ipc/mock/visitor.ts). The button shows only when the demo was built before the site:
pnpm --filter @hatoba/site demo # writes apps/site/public/demo from the release's tag
pnpm --filter @hatoba/site demo:check # after build: opens the demo in Chrome and runs it to its first approval cardLike the docs, the demo comes from the release's tag, so it shows the version people download, and a release from before the demo builds none. HATOBA_DEMO_REF=worktree builds your checkout instead, as pull requests do, and pnpm dev --mode demo in apps/desktop runs the visitors' version with hot reload.
CI also runs format and lint checks:
cargo fmt --all --check
node scripts/ci/comment-width.mjs # Rust comment lines within 100 characters, which rustfmt does not wrap
cargo clippy --workspace --all-targets -- -D warnings
pnpm lint # ESLint for the desktop frontend and packages/ui; warnings fail too
pnpm format:check # Prettier; `pnpm format` rewrites the files it reports- When you add a dependency in
workers/sync, npm 10 may fail withCannot read properties of null (reading 'edgesOut'). This is a known npm 10.x issue with resolving the optional peer dependencies of vitest. Upgrade to npm 11 or use pnpm. A plainnpm installornpm cifrom the existingpackage-lock.jsonis not affected.