M0: compilable skeleton — Kigi 0.1.0 fork surgery
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).
This commit is contained in:
commit
d6c20fc13f
2612 files changed
+1353757
No files matched your search
@@ -0,0 +1,148 @@
|
||||
//! Video playback overlay chrome (border, title, progress bar).
|
||||
//!
|
||||
//! The video frame itself is rendered via post-flush escape sequences
|
||||
//! by the caller, matching the image viewer pattern.
|
||||
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, BorderType, Borders, Widget};
|
||||
|
||||
use crate::prompt_images::VideoViewerState;
|
||||
use crate::render::safe_buf::SafeBuf;
|
||||
|
||||
/// Render the video viewer popup chrome. Returns the popup `Rect`,
|
||||
/// or `None` if the area is too small.
|
||||
pub fn render_video_overlay(
|
||||
buf: &mut Buffer,
|
||||
area: Rect,
|
||||
viewer: &VideoViewerState,
|
||||
bg: Color,
|
||||
text_fg: Color,
|
||||
border_fg: Color,
|
||||
) -> Option<Rect> {
|
||||
if area.height < 8 || area.width < 20 {
|
||||
return None;
|
||||
}
|
||||
|
||||
crate::render::color::dim_area(buf, area, bg, 0.5);
|
||||
|
||||
// 90% centered popup.
|
||||
let popup_width = ((area.width as u32 * 90) / 100)
|
||||
.max(28)
|
||||
.min(area.width as u32) as u16;
|
||||
let popup_height = ((area.height as u32 * 90) / 100)
|
||||
.max(8)
|
||||
.min(area.height as u32) as u16;
|
||||
let popup_x = area.x + (area.width.saturating_sub(popup_width)) / 2;
|
||||
let popup_y = area.y + (area.height.saturating_sub(popup_height)) / 2;
|
||||
let popup_rect = Rect::new(popup_x, popup_y, popup_width, popup_height);
|
||||
|
||||
ratatui::widgets::Clear.render(popup_rect, buf);
|
||||
buf.set_style(popup_rect, Style::default().fg(text_fg).bg(bg));
|
||||
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(Style::default().fg(border_fg).bg(bg))
|
||||
.style(Style::default().bg(bg))
|
||||
.render(popup_rect, buf);
|
||||
|
||||
// Title centered in top border.
|
||||
let title = match viewer.title {
|
||||
Some(ref name) => format!(
|
||||
" {} ({}\u{00d7}{}) ",
|
||||
name, viewer.video_width, viewer.video_height
|
||||
),
|
||||
None => format!(
|
||||
" Video ({}\u{00d7}{}) ",
|
||||
viewer.video_width, viewer.video_height
|
||||
),
|
||||
};
|
||||
let title_style = Style::default()
|
||||
.fg(text_fg)
|
||||
.bg(bg)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
let tw = title.len() as u16;
|
||||
let tx = popup_rect.x + (popup_rect.width.saturating_sub(tw)) / 2;
|
||||
buf.set_span_safe(tx, popup_rect.y, &Span::styled(&title, title_style), tw);
|
||||
|
||||
// Progress bar on the bottom border row.
|
||||
render_progress_bar(buf, popup_rect, viewer, text_fg, border_fg, bg);
|
||||
|
||||
Some(popup_rect)
|
||||
}
|
||||
|
||||
/// Render the progress bar on the popup's bottom border row.
|
||||
fn render_progress_bar(
|
||||
buf: &mut Buffer,
|
||||
popup_rect: Rect,
|
||||
viewer: &VideoViewerState,
|
||||
text_fg: Color,
|
||||
bar_dim: Color,
|
||||
bg: Color,
|
||||
) {
|
||||
let bar_y = popup_rect.y + popup_rect.height.saturating_sub(1);
|
||||
let inner_width = popup_rect.width.saturating_sub(2) as usize;
|
||||
if inner_width <= 10 {
|
||||
return;
|
||||
}
|
||||
|
||||
let icon = if viewer.playing {
|
||||
"\u{25b6}"
|
||||
} else {
|
||||
"\u{23f8}"
|
||||
};
|
||||
let time_label = format!(
|
||||
"{icon} {}/{} ",
|
||||
format_time(viewer.position_secs()),
|
||||
format_time(viewer.duration_secs),
|
||||
);
|
||||
let bar_width = inner_width.saturating_sub(time_label.len());
|
||||
if bar_width <= 4 {
|
||||
return;
|
||||
}
|
||||
|
||||
let filled = ((viewer.progress() * bar_width as f64).round() as usize).min(bar_width);
|
||||
let empty = bar_width.saturating_sub(filled);
|
||||
|
||||
let line = Line::from(vec![
|
||||
Span::styled(time_label, Style::default().fg(text_fg).bg(bg)),
|
||||
Span::styled(
|
||||
"\u{2501}".repeat(filled),
|
||||
Style::default().fg(text_fg).bg(bg),
|
||||
),
|
||||
Span::styled(
|
||||
"\u{2500}".repeat(empty),
|
||||
Style::default().fg(bar_dim).bg(bg),
|
||||
),
|
||||
]);
|
||||
|
||||
buf.set_line_safe(popup_rect.x + 1, bar_y, &line, inner_width as u16);
|
||||
}
|
||||
|
||||
fn format_time(secs: f64) -> String {
|
||||
let total = secs.round() as u64;
|
||||
format!("{}:{:02}", total / 60, total % 60)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn format_time_zero() {
|
||||
assert_eq!(format_time(0.0), "0:00");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_time_short() {
|
||||
assert_eq!(format_time(5.4), "0:05");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_time_minutes() {
|
||||
assert_eq!(format_time(90.0), "1:30");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user