Kaku is a macOS-native terminal emulator derived from WezTerm and shaped around AI-assisted terminal workflows. This guide is the shared operating context for agents working in this repository.
kaku/- CLI entry points, command flows, and user-facing configuration commands.kaku-gui/- GUI, rendering, window lifecycle, input, mouse handling, AI chat, and thekhelper binary.mux/- tabs, panes, domains, and client/server state.term/- terminal emulation and screen buffer behavior.termwiz/- terminal UI primitives.config/- Lua config loading, schema behavior, proxy settings, and versioned defaults.window/- platform windowing layer.lua-api-crates/- Rust-to-Lua API bindings.crates/- shared utility crates, including Kaku-specific AI helpers.assets/- app resources, bundled config, shell integration, and vendor assets.scripts/- build, release, and validation helpers.docs/- user and developer documentation..github/workflows/ci.yml- primary GitHub Actions workflow..github/RELEASE_NOTES.md- source for the GitHub Release title and body.
make fmt
make fmt-check
make check
make test
make dev
make app
./scripts/build.sh
./scripts/check_config_release_readiness.sh
./scripts/check_release_config.sh
./scripts/check_release_notes.shmake fmt requires the nightly Rust toolchain. Use make app for GUI, rendering, windowing, and AI overlay verification because it builds the app bundle that users run.
- Work on the current branch unless the maintainer asks for a branch or worktree.
- Keep changes inside one crate or subsystem when the problem allows it.
- Prefer targeted
rgsearches over repository-wide scans. - Inspect public APIs and cross-crate boundaries before changing shared behavior.
- Draft issue and PR replies unless the maintainer has already approved the exact public action.
- Do not modify files outside this repository without showing the intended change and getting explicit confirmation.
- Do not add instructions for the removed
website/tree unless that directory exists in the current worktree. - Keep private credentials, local keychain paths, and machine-specific release notes out of public repository docs.
- Do not propose UI i18n / multi-language menus / a
config.languagesetting. Therust-i18nbased Chinese UI localization (PR #362, commitf6cfb4b) was reverted on 2026-05-18;languageremains in the config schema as a deprecated field for backward compat only. UI strings (tab.empty_pane, menus, confirm dialogs, config TUI copy) stay as English literal strings. New UI surfaces should not introduce translation keys, locale-aware formatting, or "what if a user wants Chinese" abstractions. If a user requests a non-English UI, route to the assistant config / AI chat surface; those already accept non-English content. - Do not pre-bake provider abstractions in
kaku/src/ai_config/. Themod provider_adaptertrait scaffolding for the 9 AI providers (KakuAssistant, ClaudeCode, Codex, Copilot, Kimi, Antigravity, Gemini, FactoryDroid, OpenClaw) was deleted on 2026-05-26 after sitting at zero implementations for half a year. When provider work is actually needed, start with a single concrete migration (one PR moves KakuAssistant's four functions fromtui.rstoproviders/kaku_assistant.rs); do not spec out a trait, aProviderKindenum, or stub modules ahead of time. Save Copilot for last because its OAuth flow is the real abstraction stress test.
- For current issue and PR sweeps, read live GitHub state first with
gh issue listandgh pr list; refresh once more before final conclusions or public actions. - Before commenting on or closing an item, confirm its title, state, and author with
gh issue vieworgh pr view. - Do not close issues or PRs on local green alone. For fixes pushed to
main, wait for the new GitHub Actions run onmainto pass before posting fixed/closed replies. - Before pushing
main, rungit fetch origin mainand verifyorigin/mainhas not moved unexpectedly. If it moved, stop and revieworigin/main..HEADbefore pushing. - If an accepted PR's equivalent fix lands on
mainoutside the contributor branch, state the landed commit and co-author status in the PR before closing it.
When scope is incomplete, inspect in this order:
- User-provided repro, failing command, or failing test.
- Entry point for the behavior, usually
kaku/src/main.rs,kaku/src/cli/, orkaku-gui/src/main.rs. - Owning subsystem document and target crate.
- Immediate cross-crate boundary used by the call path.
- Narrow tests, fixtures, snapshots, or scripts that reproduce the behavior.
For AI-facing behavior, inspect in this order:
- CLI and assistant configuration under
kaku/src/ai_config/,kaku/src/assistant_config.rs, andconfig/src/proxy.rs. - GUI AI state and transport under
kaku-gui/src/ai_*,kaku-gui/src/ai_chat_engine/, andkaku-gui/src/cli_chat/. - Overlay UI under
kaku-gui/src/overlay/ai_chat/. - Shared helpers in
crates/kaku-ai-utils/.
For Ctrl+letter not working in a raw-mode TUI (the most common shape: Ctrl+C / Ctrl+R works in plain shell but not inside a TUI overlay), inspect in this order:
- AppKit menu
keyEquivalentinterceptingkeyDownbefore the terminal sees it. Enableconfig.debug_key_events = true, restart the app, thengrep 'key_event.*CTRL' ~/.local/share/kaku/kaku-gui-log-<pid>.txt. If the log shows onlykey_is_down: falseand no matchingkey_is_down: true, the AppKit menu absorbed the event; do not chase termwiz or PTY. - Cooked-mode tests (
cat -vshowing^C) do not rule out menu interception. Reproduce inside a raw-mode TUI before forming a hypothesis. - Only after step 1 rules out menu interception, inspect termwiz encoding (
crates/termwiz/src/input.rs), then PTY / termios state.
| Subsystem | Guide | Scope |
|---|---|---|
| GUI | kaku-gui/AGENTS.md |
Rendering, window lifecycle, input, mouse |
| Mux | mux/AGENTS.md |
Tabs, panes, domains, client/server |
| Terminal | term/AGENTS.md |
VT emulation, screen buffer |
| Config | config/AGENTS.md |
Lua loading, schema, config reload |
| Termwiz | termwiz/AGENTS.md |
TUI primitives and widgets |
| Lua API | lua-api-crates/AGENTS.md |
Rust-to-Lua bindings |
| Crates | crates/AGENTS.md |
Shared utility crates |
| Change type | Command |
|---|---|
| Rust compile check | make check |
| Rust logic change | make test |
| Formatting | make fmt-check |
| GUI or rendering change | make app |
| Config release change | ./scripts/check_config_release_readiness.sh and ./scripts/check_release_config.sh |
| Release note change | ./scripts/check_release_notes.sh |
| Release-adjacent change | make fmt && make check && make test, then make app |
For GUI or rendering issues, read kaku-gui/AGENTS.md first and verify with make app, not only make dev.
- AI chat and shell flows are active product surfaces. Preserve
fast_model, proxy config, inline#query status, syntax highlighting, approval flow, and conversation state behavior. - Config release work currently centers on
config_version21. Config schema changes must update bundled defaults, docs, release checks, and migration behavior together. v21 addssmart_tab_mode, retypestab/pane/window_close_confirmationfrom bool to theCloseConfirmationenum (NeverPrompt/SmartPrompt/AlwaysPrompt, with bool still accepted for backward compat) and defaults the bundledkaku.luafor all three toSmartPrompt; the schema fallback when a field is unset isAlwaysPrompt. v21 also accepts the removedlanguageoption as a deprecated field for backward compat. - GUI regressions can come from overlay resize, pane split/removal, macOS worker thread lifetime, WebGPU surface reconfigure, tab bar spacing, and alternate-screen wheel scroll behavior.
- Startup performance depends on caching shell user vars, Lua bytecode, early appearance queries, GLSL version, and built-in fonts. Do not invalidate those caches without measurement.
- Notification actions that call back into Kaku should resolve bundled executables relative to the running app, not an assumed system path.
Tag format is V0.x.x. scripts/release.sh is the source of truth for tagged releases. The GitHub Release title comes from the first heading in .github/RELEASE_NOTES.md.
- Single-crate behavior belongs in that crate's
AGENTS.md. - Cross-crate behavior should update every affected subsystem guide.
- Build, CI, release, and maintainer workflow changes belong in this root file.
- Shared agent instructions belong in tracked docs. Personal overrides belong in ignored local files.
- One-off review reports, scorecards, and diagnostic snapshots are evidence, not durable project docs. Extract stable rules or verification gates into
AGENTS.md,CLAUDE.md, subsystem guides, scripts, or tests, then remove the transient report. - Do not hide user-visible behavior changes inside maintainability or cleanup patches. New UI, config fields, defaults, or workflow permissions should be split into their own change unless the maintainer explicitly approved that scope.