Kaku Documentation

repository·main·Indexed 26 days ago

https://github.com/tw93/kaku

A high-performance, macOS-only terminal emulator based on a customized fork of WezTerm. Kaku is optimized for AI-assisted coding workflows, featuring built-in AI command generation, error recovery, and an AI chat interface. The project includes several Rust crates such as wezterm-bidi for Unicode Bidirectional Algorithm implementation, vtparse for escape sequence parsing, and termwiz for terminal manipulation and display abstractions.

Tokens
29.6K
Snippets
71
Records
257
Agent score
88%

What's inside Kaku

  1. Overview of vtparse

    main

    vtparse is a low-level implementation of a parser for escape and control sequences, based on the DEC ANSI Parser. It is modified to support UTF-8 sequences.

    Note that vtparse is a low-level parser: it categorizes basic sequence types but does not assign semantic meaning to them. If you require semantic parsing, consider using termwiz::escape::parser::Parser from the termwiz crate.

  2. Overview of Cairo 2D Graphics Library

    main

    Cairo is a multi-platform 2D graphics library designed to produce consistent output across various media while utilizing hardware acceleration when available. It supports operations similar to PostScript and PDF, including:

    • Stroking and filling cubic Bézier splines
    • Transforming and compositing translucent images
    • Antialiased text rendering
    • Affine transformations (scale, rotation, shear, etc.)

    Supported output targets include:

    • Surface Backends: X Window System (Xlib, XCB), Quartz (macOS), Win32 (Windows), and image buffers.
    • File Formats: PDF, PostScript, and SVG.
    • Experimental: OpenGL.
  3. Overview of wezterm-bidi

    main

    wezterm-bidi is a pure Rust implementation of the Unicode Bidirectional Algorithm (UBA). It is designed for high conformance, passing 100% of the BidiTest.txt and BidiCharacterTest.txt test cases (approximately 780,000 cases).

    Key capabilities include:

    • Resolving embedding levels.
    • Reordering line ranges.

    Technical constraints:

    • It is a no_std crate.
    • It requires alloc.
    • It is independent of the wezterm codebase, despite being developed for it.
  4. Overview of wezterm-term

    main

    The wezterm-term crate provides the core virtual terminal emulator implementation used by WezTerm. It is a full-featured terminal engine that handles terminal escape sequence parsing, keyboard and mouse input encoding, and screen cell modeling (including scrollback). It supports advanced features like Sixel and iTerm2 image support, OSC 8 Hyperlinks, and various terminal cell attributes.

    Note: This crate does not include a GUI or PTY management. You are responsible for providing a std::io::Write implementation (e.g., connected to a PTY) and feeding bytes into the terminal model.

  5. Overview of the termwiz crate

    main
    termwiz is a Rust crate designed for applications that need to display data to a terminal or build a terminal emulator. It provides high-level abstractions for terminal manipulation, including support for modern features like True Color, hyperlinks, and graphics displays (sixel and iterm style).
  6. Understand the purpose of lua-api-crates

    main
    The crates located in the lua-api-crates directory provide the underlying modules and functions that power the WezTerm Lua configuration file and its interface. These crates are registered into the Lua configuration environment via env-bootstrap.
  7. Understand the config_version mechanism

    main

    Kaku uses a monotonically increasing integer called config_version to manage configuration schema changes and shell integration regeneration.

    • The single source of truth for the current version is the file: assets/shell-integration/config_version.txt.
    • A version bump is required on every release, even if no schema changes occur. This ensures that updates regenerate bundled shell integrations (like zsh or fish integrations) to pick up new logic or fixes.
    • When updating Kaku, an incremented config_version triggers the regeneration of bundled integrations, such as the zsh integration or SSH wrappers.
  8. Integrate Lazygit and Yazi

    main

    Kaku provides quick access to common terminal tools:

    • Lazygit: Press Cmd + Shift + G to launch in the current pane. Install via brew install lazygit or kaku init.
    • Yazi: Press Cmd + Shift + Y to launch in the current pane. The shell wrapper y also launches Yazi and syncs the working directory on exit. Kaku automatically syncs your Yazi theme to match Kaku's color scheme. Install via brew install yazi or kaku init.

    To provision these and other optional tools, run:

    kaku init
  9. Use Kaku's standalone AI chat

    main

    Start Kaku's standalone AI chat from any shell. This command is a discoverable alias for the bundled k helper. The chat uses ~/.config/kaku/assistant.toml and shares conversation/memory files with the Cmd + L overlay.

    In interactive mode, you can use the following slash commands:

    • /new
    • /resume
    • /clear
    • /status
    • /memory
    • /exit
    kaku chat                 # open interactive chat
    kaku chat "explain this"  # one-shot prompt
  10. Reset Kaku configuration and integration

    main

    Use kaku reset to remove Kaku-managed shell and tmux integration, Kaku-managed git delta defaults, selected Kaku state, and managed theme blocks in ~/.config/kaku/kaku.lua.

    Warning: Use with caution. User-authored Lua outside of managed blocks is preserved. If you want to restore shell integration after a reset, run kaku init.

    kaku reset
  11. Install Kaku via Homebrew

    main

    To avoid conflicts with an unrelated package named kaku on Homebrew, install Kaku using the official tap:

    brew install tw93/tap/kakuku

    If you encounter checksum errors during updates, use brew upgrade tw93/tap/kakuku instead.

    brew install tw93/tap/kakuku
  12. Kaku Keyboard Shortcuts

    main

    Kaku provides several built-in shortcuts for window, tab, and pane management, as well as AI features.

    ActionShortcut
    New TabCmd + T
    New WindowCmd + N
    Close Tab/PaneCmd + W
    Navigate TabsCmd + Shift + [ / ] or Cmd + 1–9
    Navigate PanesCmd + Opt + Arrows
    Split Pane VerticalCmd + D
    Split Pane HorizontalCmd + Shift + D
    Open Settings PanelCmd + ,
    AI PanelCmd + Shift + A
    AI ChatCmd + L
    Apply AI SuggestionCmd + Shift + E
    Open LazygitCmd + Shift + G
    Yazi File ManagerCmd + Shift + Y or y
    Clear ScreenCmd + K