Hard fork of xai-org/grok-build (Apache-2.0) re-targeted as Kigi, an
unofficial Kimi Code CLI community build.
Rename & identity
- 72 xai-*/xai-grok-* crates -> kigi-* (explicit: xai-grok-pager-bin ->
kigi-bin [binary `kigi`], xai-grok-pager -> kigi-tui; rest mechanical);
ptyctl, ptyctl-cli, third_party/ unchanged; proto package
xai.grok.tools.v1 -> kigi.tools.v1
- Config home ~/.kigi (KIGI_SHARE_DIR override), env prefix GROK_* ->
KIGI_*, `kigi --version` carries the unofficial-community-build notice
- clap identity, help text, startup banner, prompt templates rebranded
(templates re-encrypted)
Deletions (PRD removal list #5/#6/#7/#9/#10)
- voice input (xai-grok-voice) and all TUI wiring
- telemetry: Mixpanel client, external OTel stream, Sentry, OTLP layers,
trace/GCS/S3 upload queues (kigi-file-utils halved), workspace upload
module & dc_log, heap-profile uploader, auth-diagnostics uploader,
session-analytics halves of feedback; local zero-egress observability
preserved in new kigi-log crate (unified log, --debug firehose,
subsystem file logs, opt-in instrumentation)
- announcements (crate, remote-settings fields, TUI surfaces)
- plugin marketplace (crate, sources/browse/CTA/extensions-modal tab);
direct plugin install/uninstall/update via kigi-agent git_install kept
- relay/gateway/assets endpoints and features (agent relay, headless
relay transport, gateway bridge, LeaderEnvUrls); leader IPC socket now
~/.kigi/leader.sock + KIGI_LEADER_SOCKET, no ws-url derivation
- functional types rehomed instead of deleted: PermissionMode ->
kigi-config-types, McpInitStrategy -> kigi-mcp, PrCreationSource ->
session signals, TerminalDiagnostics -> kigi-pager-render, agent_id ->
shell util
Endpoints
- kigi-env rewritten: single production KigiEndpoints {coding_api_base_url
https://api.kimi.com/coding/v1 (KIGI_CODE_BASE_URL), oauth_host
https://auth.kimi.com (KIGI_OAUTH_HOST), update_base_url (GitHub
Releases API), upgrade_page_url}; GrokBuildEnvironment enum deleted
Toolchain & workspace hygiene
- Rust 1.97.0 pinned; edition 2024; full cargo update; git2 hoisted to
workspace at 0.21 (Option->Result API migration), quick-xml 0.41
- Root Cargo.toml hand-maintained (PRD §8.1): version 0.1.0 inherited by
all members, members sorted, unused deps pruned
- cargo-deny advisories gate (deny.toml with documented transitive
exceptions); CI workflow (check/clippy/fmt/deny/test, macOS+Linux)
- cross-crate test seams re-gated behind `test-support` cargo feature;
insta snapshot baselines renamed to the kigi_tui prefix
- clippy --workspace --all-targets: zero warnings; fmt clean
Fixes surfaced by the port
- updater probe/installer divergence (bin/kigi vs bin/grok symlink set)
- idle model-metadata refresh dead under KIGI_CODE_BASE_URL override
(new is_effective_coding_endpoint_url, loopback+override aware)
- macOS symlinked-TMPDIR fixture canonicalization (foreign_sessions,
fast-worktree); RSS measurement tests serialized via serial_test
Docs & legal (Apache §4)
- NOTICE added (upstream attribution + change statement); THIRD-PARTY
notices sustained; kigi-tools ported-code notices extended; README,
CONTRIBUTING, SECURITY, AGENTS.md rewritten
Out of scope for M0 (tracked): Kimi auth/inference (M1), search/fetch,
command parity, config import (M2), Computer Hub excision & final
brand-token sweep (M2), distribution & self-update rewrite (M3).
119 lines
5.9 KiB
Rust
119 lines
5.9 KiB
Rust
//! Minimal (scrollback-native) render mode — `grok --minimal`.
|
|
//!
|
|
//! In this mode finalized conversation blocks are printed once into the
|
|
//! terminal's *native* scrollback (via `kigi_ratatui_inline::Terminal::insert_before`,
|
|
//! reusing `EntryRenderer`) while a small pinned live region holds the
|
|
//! running-turn status, the prompt, and a minimal status line. The interactive
|
|
//! `ScrollbackPane` (scroll, fold, selection, mouse) is not used; the terminal
|
|
//! owns history.
|
|
//!
|
|
//! - [`commit`] — committed-frontier logic, display policy, and the per-frame
|
|
//! commit-to-scrollback pass.
|
|
//! - [`live`] — the pinned live region (tail + status + prompt).
|
|
//! - [`todo`] — the persistent todo panel shown above the prompt.
|
|
//! - [`auth`] — the in-region sign-in flow shown before a session exists.
|
|
//! - [`overlay`] — the inline-overlay host (prompt-anchored dropdowns; grows /
|
|
//! shrinks the live viewport).
|
|
//!
|
|
//! # Wiring
|
|
//!
|
|
//! `kigi-tui` (the lib) does **not** depend on this crate — that would be
|
|
//! a cargo dependency cycle, since this crate reads deeply into the pager's
|
|
//! [`AppView`] / view model. Instead the pager exposes an inversion-of-control
|
|
//! seam ([`kigi_tui::minimal_hook`]) of function pointers, and the
|
|
//! composition-root binary (`kigi-bin`) calls [`install`] once at
|
|
//! startup to register this crate's [`draw`] entry point. When the seam is not
|
|
//! installed the pager's minimal-mode branches are inert.
|
|
|
|
pub mod auth;
|
|
pub mod commit;
|
|
pub mod full_view;
|
|
pub mod live;
|
|
pub mod overlay;
|
|
pub mod panel;
|
|
pub mod plan;
|
|
pub mod todo;
|
|
pub mod welcome;
|
|
|
|
#[cfg(test)]
|
|
mod guard;
|
|
|
|
use crossterm::QueueableCommand;
|
|
use crossterm::terminal::BeginSynchronizedUpdate;
|
|
|
|
use kigi_tui::app::PagerTerminal;
|
|
use kigi_tui::app::app_view::AppView;
|
|
|
|
/// Per-frame entry point for minimal mode, called from [`AppView::draw`].
|
|
///
|
|
/// Order matters:
|
|
/// 0. Open a synchronized update and adopt the current terminal size (see
|
|
/// below), so every write this frame — commits *and* the live region —
|
|
/// presents atomically at the right dimensions.
|
|
/// 1. Commit the pending welcome card (fresh session / `/new`) so it lands
|
|
/// above the first conversation block, and push any ready plan into
|
|
/// scrollback (`plan::maybe_commit_plan`) so it commits like a normal block
|
|
/// this frame — the live region then holds only the plan's decision controls.
|
|
/// 2. Size the viewport to its **post-commit** height (see
|
|
/// [`overlay::sync_viewport`] / [`live::tail_height`]). This runs *before* the
|
|
/// commit so that step 3's `insert_before` prints each finalized block and
|
|
/// repositions the correctly-sized viewport to sit directly after it
|
|
/// (content-anchored — the prompt follows the content, and once the screen is
|
|
/// full that position is the bottom). Otherwise the viewport was still at its
|
|
/// tall streaming height when the block committed, and the following shrink
|
|
/// stranded the prompt at the top of the screen ("input snaps to the top").
|
|
/// 3. Commit finalized blocks into native scrollback (each `insert_before`
|
|
/// scrolls committed rows up above the pinned viewport), then re-print any
|
|
/// `Ctrl+E` / `/expand` re-prints fully expanded below.
|
|
/// 4. Redraw the live region (tail · status · overlay · prompt) into the
|
|
/// viewport's final position.
|
|
///
|
|
/// ## Why step 0 exists (resize + flicker)
|
|
///
|
|
/// **Resize:** `draw_frame` runs `terminal.autoresize()` — but that is the
|
|
/// *last* step of this function, while the commit passes read
|
|
/// `viewport_area().width` first. On the frame that processes a terminal
|
|
/// resize, a block finalizing in that same frame would be laid out and printed
|
|
/// at the *stale* width; a shrink then hard-wraps every over-wide row on the
|
|
/// real terminal, permanently garbling the print-once committed copy. Adopting
|
|
/// the new size up front closes that window (a no-op on non-resize frames).
|
|
///
|
|
/// **Flicker:** the commit `insert_before`s scroll + repaint the screen and
|
|
/// flush per chunk. Without a synchronized update around them, a multi-block
|
|
/// commit (thinking + tool + message finalizing together) presents as several
|
|
/// visible scroll/paint bursts before the live region repaints. Opening the
|
|
/// synchronized update *before* the commits batches the whole frame — commits,
|
|
/// viewport reposition, and live redraw — into one atomic present. The
|
|
/// matching `EndSynchronizedUpdate` is emitted by `draw_frame` (step 4), which
|
|
/// every path through this function reaches; its own inner
|
|
/// `BeginSynchronizedUpdate` is redundant-but-harmless (DEC 2026 is a mode,
|
|
/// not a counter — the first End closes it).
|
|
pub fn draw(app: &mut AppView, terminal: &mut PagerTerminal) {
|
|
let _ = terminal.backend_mut().queue(BeginSynchronizedUpdate);
|
|
let _ = terminal.autoresize();
|
|
// Pending permission/question marks are synced ONCE, up front, so the
|
|
// viewport sizing (`sync_viewport` / `tail_height` / `will_commit`) and the
|
|
// commit pass judge committability against the same state (see
|
|
// `commit::sync_pending_marks`).
|
|
commit::sync_pending_marks(app);
|
|
// Advance any in-progress /transcript build by one time-budgeted slice
|
|
// (arms `pending_pager_path` when done; see `full_view::pump_transcript`).
|
|
full_view::pump_transcript(app);
|
|
welcome::maybe_commit_welcome(app, terminal);
|
|
plan::maybe_commit_plan(app);
|
|
overlay::sync_viewport(app, terminal);
|
|
commit::commit_active(app, terminal);
|
|
commit::expand_pending(app, terminal);
|
|
live::draw_live(app, terminal);
|
|
}
|
|
|
|
/// Register the minimal-mode render hooks with `kigi-tui`.
|
|
///
|
|
/// Call this exactly once, early in the binary's `main`, before any frame is
|
|
/// drawn. It installs the function-pointer seam so the pager's
|
|
/// `ScreenMode::Minimal` branches dispatch into this crate. Idempotent:
|
|
/// subsequent calls are ignored (see [`kigi_tui::minimal_hook`]).
|
|
pub fn install() {
|
|
kigi_tui::minimal_hook::install(kigi_tui::minimal_hook::MinimalHooks { draw });
|
|
}
|