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).
110 lines
4.5 KiB
Rust
110 lines
4.5 KiB
Rust
//! Interactive playground for mermaid diagrams in the real scrollback path.
|
|
//!
|
|
//! Builds a [`ScrollbackState`] containing an agent message whose markdown holds
|
|
//! a mermaid code block, then renders it through the production
|
|
//! [`ScrollbackPane`] so the diagram can be eyeballed exactly as the TUI draws
|
|
//! it (including word-wrapping). Pick a sample with `MERMAID_SAMPLE=<n>`.
|
|
//!
|
|
//! Controls: arrows / PageUp / PageDown scroll, `q` / `Esc` / `Ctrl-Q` quit.
|
|
|
|
use std::io::{self, stdout};
|
|
use std::time::Duration;
|
|
|
|
use crossterm::ExecutableCommand;
|
|
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
|
|
use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
|
|
use kigi_tui::scrollback::{RenderBlock, ScratchBuffer, ScrollbackPane, ScrollbackState};
|
|
use ratatui::Terminal;
|
|
use ratatui::backend::CrosstermBackend;
|
|
use ratatui::layout::Rect;
|
|
|
|
const SAMPLES: &[(&str, &str)] = &[
|
|
(
|
|
"draw a flowchart for the deploy decision",
|
|
"Here is the deploy flow:\n\n```mermaid\nflowchart TD\n A[Start] --> B{Is it working?}\n B -->|Yes| C[Ship it]\n B -->|No| D[Debug]\n D --> B\n```\n\nLet me know if you want changes.",
|
|
),
|
|
(
|
|
"show the request path",
|
|
"Sure:\n\n```mermaid\ngraph TD\n A[Client] --> B[Load Balancer]\n B --> C[Server 1]\n B --> D[Server 2]\n C --> E[(Database)]\n D --> E\n```\n",
|
|
),
|
|
(
|
|
"a simple pipeline left to right",
|
|
"```mermaid\nflowchart LR\n A[Ingest] --> B[Transform] --> C[Validate] --> D[Store]\n```\n",
|
|
),
|
|
(
|
|
"sequence diagram please",
|
|
"```mermaid\nsequenceDiagram\n Alice->>Bob: Hello Bob\n Bob-->>Alice: Hi Alice\n```\n",
|
|
),
|
|
(
|
|
"coffee-making decision flowchart",
|
|
"Here's a coffee-making decision process:\n\n```mermaid\nflowchart TD\n A[Wake up] --> B{Need caffeine?}\n B -->|Yes| C[Go to kitchen]\n B -->|No| D[Drink water]\n C --> E{Beans available?}\n D --> F[Stay hydrated]\n E -->|Yes| G[Grind beans]\n E -->|No| H[Use instant coffee]\n G --> I[Brew espresso]\n H --> J[Boil water]\n I --> K{Add milk?}\n J --> K\n K -->|Yes| L[Make latte]\n K -->|No| M[Drink black]\n L --> N[Enjoy coffee]\n M --> N\n N --> O[Start the day]\n```\n",
|
|
),
|
|
];
|
|
|
|
fn main() -> io::Result<()> {
|
|
let sample = std::env::var("MERMAID_SAMPLE")
|
|
.ok()
|
|
.and_then(|s| s.parse::<usize>().ok())
|
|
.unwrap_or(0)
|
|
% SAMPLES.len();
|
|
let (prompt, answer) = SAMPLES[sample];
|
|
|
|
let mut scrollback = ScrollbackState::new();
|
|
scrollback.push_block(RenderBlock::user_prompt(prompt));
|
|
scrollback.push_block(RenderBlock::agent_message(answer));
|
|
let mut scratch = ScratchBuffer::new();
|
|
|
|
terminal::enable_raw_mode()?;
|
|
stdout().execute(EnterAlternateScreen)?;
|
|
let backend = CrosstermBackend::new(stdout());
|
|
let mut terminal = Terminal::new(backend)?;
|
|
|
|
let mut first = true;
|
|
loop {
|
|
terminal.draw(|f| {
|
|
let area = f.area();
|
|
scrollback.prepare_layout(area.width, area.height);
|
|
if first {
|
|
scrollback.scroll_to_entry_top(0);
|
|
first = false;
|
|
}
|
|
let mut buf = ratatui::buffer::Buffer::empty(area);
|
|
let _ = ScrollbackPane::new().active(true).render_with_scratch(
|
|
Rect::new(area.x, area.y, area.width, area.height),
|
|
&mut buf,
|
|
&scrollback,
|
|
&mut scratch,
|
|
);
|
|
for y in 0..area.height {
|
|
for x in 0..area.width {
|
|
if let Some(src) = buf.cell((area.x + x, area.y + y))
|
|
&& let Some(dst) = f.buffer_mut().cell_mut((area.x + x, area.y + y))
|
|
{
|
|
*dst = src.clone();
|
|
}
|
|
}
|
|
}
|
|
})?;
|
|
|
|
if event::poll(Duration::from_millis(100))?
|
|
&& let Event::Key(KeyEvent {
|
|
code, modifiers, ..
|
|
}) = event::read()?
|
|
{
|
|
match code {
|
|
KeyCode::Char('q') | KeyCode::Esc => break,
|
|
KeyCode::Char('c') if modifiers.contains(KeyModifiers::CONTROL) => break,
|
|
KeyCode::Up => scrollback.scroll_up(2),
|
|
KeyCode::Down => scrollback.scroll_down(2),
|
|
KeyCode::PageUp => scrollback.scroll_up(15),
|
|
KeyCode::PageDown => scrollback.scroll_down(15),
|
|
_ => {}
|
|
}
|
|
}
|
|
}
|
|
|
|
stdout().execute(LeaveAlternateScreen)?;
|
|
terminal::disable_raw_mode()?;
|
|
Ok(())
|
|
}
|