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,169 @@
|
||||
//! `/terminal-setup` — diagnose terminal, color/theme, and clipboard setup.
|
||||
//!
|
||||
//! Runs the same diagnostics engine used for startup warnings and formats
|
||||
//! the results as a user-readable message. This gives users an on-demand
|
||||
//! way to check their environment and see fix instructions.
|
||||
|
||||
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
|
||||
use crate::terminal::TerminalName;
|
||||
|
||||
pub struct TerminalSetupCommand;
|
||||
|
||||
impl SlashCommand for TerminalSetupCommand {
|
||||
fn name(&self) -> &str {
|
||||
"terminal-setup"
|
||||
}
|
||||
|
||||
fn aliases(&self) -> &[&str] {
|
||||
&["terminal-check", "terminal-info"]
|
||||
}
|
||||
|
||||
fn description(&self) -> &str {
|
||||
"Check terminal, color, and clipboard setup"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"/terminal-setup"
|
||||
}
|
||||
|
||||
fn run(&self, _ctx: &mut CommandExecCtx, _args: &str) -> CommandResult {
|
||||
let ctx = crate::terminal::terminal_context();
|
||||
let query = crate::diagnostics::LiveTmuxQuery;
|
||||
let is_control_mode = crate::terminal::detect_tmux_control_mode(ctx);
|
||||
let mut warnings = crate::diagnostics::collect_startup_warnings(
|
||||
ctx,
|
||||
&query,
|
||||
is_control_mode,
|
||||
_ctx.screen_mode.is_fullscreen(),
|
||||
);
|
||||
// Live-environment check, kept out of `collect_startup_warnings` so
|
||||
// its tests stay hermetic (same pattern as the WezTerm warning below).
|
||||
warnings.extend(crate::diagnostics::diagnose_wayland_data_control_live());
|
||||
// WezTerm without the Kitty keyboard protocol: surface the fix
|
||||
// alongside the other issues. By the time the user runs
|
||||
// /terminal-setup the async XTVERSION reply has landed, so this
|
||||
// also catches WezTerm over SSH (env brand Unknown, self-report
|
||||
// "WezTerm <version>").
|
||||
let wezterm_warning = crate::diagnostics::wezterm_kitty_keyboard_warning(
|
||||
ctx,
|
||||
crate::app::kitty_flags_pushed(),
|
||||
crate::terminal::xtversion::detected(),
|
||||
);
|
||||
let wezterm_kkp_off = wezterm_warning.is_some();
|
||||
warnings.extend(wezterm_warning);
|
||||
// Color not in collect_startup_warnings (noisy on limited terminals).
|
||||
let color_level = crate::theme::color_support::get();
|
||||
warnings.extend(crate::diagnostics::color_support_warning(
|
||||
color_level,
|
||||
ctx.brand,
|
||||
ctx.is_tmux_backed(),
|
||||
&ctx.tmux_config_path(),
|
||||
));
|
||||
let route = crate::clipboard::clipboard_route();
|
||||
let is_ssh = kigi_shell::util::clipboard::is_remote_session();
|
||||
|
||||
let mut out = String::new();
|
||||
|
||||
// -- Environment --
|
||||
out.push_str("Environment\n");
|
||||
out.push_str(&format!(" terminal {}\n", ctx.brand));
|
||||
if let Some(v) = crate::terminal::xtversion::detected() {
|
||||
out.push_str(&format!(" xtversion {}\n", v));
|
||||
}
|
||||
out.push_str(&format!(" multiplexer {}\n", ctx.multiplexer));
|
||||
if let Some(ref byobu) = ctx.byobu {
|
||||
out.push_str(&format!(" byobu {}\n", byobu));
|
||||
}
|
||||
out.push_str(&format!(
|
||||
" ssh {}\n",
|
||||
if is_ssh { "yes" } else { "no" }
|
||||
));
|
||||
out.push_str(&crate::diagnostics::format_color_env_line(color_level));
|
||||
out.push_str(&crate::diagnostics::format_themes_env_line(color_level));
|
||||
|
||||
let kb = ctx.keyboard_capabilities();
|
||||
if kb.modifier_delivery.benefits_from_rescue() || kb.enter_needs_rescue() {
|
||||
let rescue = if cfg!(target_os = "macos") {
|
||||
"OS rescue active"
|
||||
} else {
|
||||
"OS rescue unavailable on this platform"
|
||||
};
|
||||
out.push_str(&format!(
|
||||
" keyboard {} ({})\n",
|
||||
kb.modifier_delivery.label(),
|
||||
rescue
|
||||
));
|
||||
}
|
||||
|
||||
// Some terminals can't distinguish Shift+Enter from bare Enter at
|
||||
// the byte level because the Kitty keyboard protocol isn't
|
||||
// negotiated (VTE < 0.82, or VS Code's xterm.js which mis-encodes
|
||||
// shifted keys). Point users at Alt+Enter, which is reliably
|
||||
// delivered as ESC+CR. Suppressed when the WezTerm warning fired:
|
||||
// stock WezTerm binds Alt+Enter to ToggleFullScreen, so advertising
|
||||
// it would contradict that warning's `\`+Enter guidance.
|
||||
if ctx.shift_enter_unavailable() && !wezterm_kkp_off {
|
||||
let detail = if ctx.vte_version.is_some() || ctx.brand == TerminalName::Vte {
|
||||
match ctx.vte_version.as_deref() {
|
||||
Some(v) => format!("VTE {v}; need >= 8200 for Shift+Enter"),
|
||||
None => "legacy VTE; need VTE >= 0.82 for Shift+Enter".to_owned(),
|
||||
}
|
||||
} else if matches!(
|
||||
ctx.brand,
|
||||
TerminalName::VsCode
|
||||
| TerminalName::Cursor
|
||||
| TerminalName::Windsurf
|
||||
| TerminalName::Zed
|
||||
) {
|
||||
format!("{}: xterm.js can't distinguish Shift+Enter", ctx.brand)
|
||||
} else {
|
||||
"no Kitty keyboard protocol; Shift+Enter == Enter".to_owned()
|
||||
};
|
||||
out.push_str(&format!(" newline Alt+Enter ({detail})\n"));
|
||||
}
|
||||
|
||||
// -- Clipboard --
|
||||
out.push_str("\nClipboard routes\n");
|
||||
out.push_str(&format!(
|
||||
" native {} (tool: {})\n",
|
||||
if route.native { "active" } else { "off" },
|
||||
kigi_shell::util::clipboard::native_tool_name(),
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" tmux buffer {}\n",
|
||||
if route.tmux_buffer { "active" } else { "off" }
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" osc 52 {}\n",
|
||||
if route.osc52 { "active" } else { "off" }
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" data-control {}\n",
|
||||
crate::clipboard::wayland_data_control_label()
|
||||
));
|
||||
|
||||
// -- Diagnostics --
|
||||
if warnings.is_empty() {
|
||||
out.push_str("\nNo issues found.\n");
|
||||
} else {
|
||||
out.push_str(&format!("\n{} issue(s)\n", warnings.len()));
|
||||
for w in &warnings {
|
||||
out.push_str(&format!("\n [!] {}\n", w.message));
|
||||
match (w.fix.as_deref(), w.config_path.as_deref()) {
|
||||
(Some(fix), Some(path)) => {
|
||||
out.push_str(&format!(" Fix: place `{}` in {}\n", fix, path));
|
||||
}
|
||||
(Some(fix), None) => {
|
||||
out.push_str(&format!(" Fix: run `{}`\n", fix));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some(note) = w.note.as_deref() {
|
||||
out.push_str(&format!(" Note: {}\n", note));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommandResult::Message(out)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user