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).
123 lines
3.3 KiB
Rust
123 lines
3.3 KiB
Rust
//! Mock file system implementation for testing.
|
|
|
|
use std::collections::HashMap;
|
|
use std::path::{Path, PathBuf};
|
|
use std::sync::Arc;
|
|
use tokio::sync::RwLock;
|
|
|
|
use crate::computer::types::{AsyncFileSystem, ComputerError};
|
|
|
|
/// In-memory file system for testing.
|
|
/// Thread-safe and async-compatible.
|
|
pub struct MockFs {
|
|
files: Arc<RwLock<HashMap<PathBuf, Vec<u8>>>>,
|
|
}
|
|
|
|
impl Default for MockFs {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|
|
|
|
impl MockFs {
|
|
/// Create a new empty mock file system.
|
|
pub fn new() -> Self {
|
|
Self {
|
|
files: Arc::new(RwLock::new(HashMap::new())),
|
|
}
|
|
}
|
|
|
|
/// Set a file's contents directly (for test setup).
|
|
pub async fn set_file(&self, path: impl AsRef<Path>, content: &[u8]) {
|
|
self.files
|
|
.write()
|
|
.await
|
|
.insert(path.as_ref().to_path_buf(), content.to_vec());
|
|
}
|
|
|
|
/// Get a file's contents directly (for test assertions).
|
|
pub async fn get_file(&self, path: impl AsRef<Path>) -> Option<Vec<u8>> {
|
|
self.files.read().await.get(path.as_ref()).cloned()
|
|
}
|
|
|
|
/// Check if a file exists.
|
|
pub async fn exists(&self, path: impl AsRef<Path>) -> bool {
|
|
self.files.read().await.contains_key(path.as_ref())
|
|
}
|
|
|
|
/// List all files in the mock filesystem.
|
|
pub async fn list_files(&self) -> Vec<PathBuf> {
|
|
self.files.read().await.keys().cloned().collect()
|
|
}
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl AsyncFileSystem for MockFs {
|
|
async fn read_file(&self, path: &Path) -> Result<Vec<u8>, ComputerError> {
|
|
self.files.read().await.get(path).cloned().ok_or_else(|| {
|
|
ComputerError::IOError(
|
|
format!("File not found: {}", path.display()),
|
|
Some(std::io::ErrorKind::NotFound),
|
|
)
|
|
})
|
|
}
|
|
|
|
async fn write_file(&self, path: &Path, data: &[u8]) -> Result<(), ComputerError> {
|
|
self.files
|
|
.write()
|
|
.await
|
|
.insert(path.to_path_buf(), data.to_vec());
|
|
Ok(())
|
|
}
|
|
|
|
async fn delete_file(&self, path: &Path) -> Result<(), ComputerError> {
|
|
self.files.write().await.remove(path);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[tokio::test]
|
|
async fn test_mock_fs_read_write() {
|
|
let fs = MockFs::new();
|
|
|
|
// File doesn't exist initially
|
|
assert!(fs.read_file(Path::new("/test.txt")).await.is_err());
|
|
|
|
// Write a file
|
|
fs.write_file(Path::new("/test.txt"), b"hello world")
|
|
.await
|
|
.unwrap();
|
|
|
|
// Read it back
|
|
let content = fs.read_file(Path::new("/test.txt")).await.unwrap();
|
|
assert_eq!(content, b"hello world");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_mock_fs_delete() {
|
|
let fs = MockFs::new();
|
|
|
|
fs.write_file(Path::new("/test.txt"), b"hello")
|
|
.await
|
|
.unwrap();
|
|
assert!(fs.exists(Path::new("/test.txt")).await);
|
|
|
|
fs.delete_file(Path::new("/test.txt")).await.unwrap();
|
|
assert!(!fs.exists(Path::new("/test.txt")).await);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_mock_fs_set_file() {
|
|
let fs = MockFs::new();
|
|
|
|
fs.set_file("/preset.txt", b"preset content").await;
|
|
|
|
let content = fs.read_file(Path::new("/preset.txt")).await.unwrap();
|
|
assert_eq!(content, b"preset content");
|
|
}
|
|
}
|