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).
160 lines
4.8 KiB
Rust
160 lines
4.8 KiB
Rust
//! Commands sent to the HunkTrackerActor.
|
|
|
|
use std::collections::HashSet;
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
use tokio::sync::oneshot;
|
|
|
|
use crate::types::{
|
|
FileContentEntry, FileHunkData, Hunk, HunkAction, HunkActionError, HunkId, HunkSourceFilter,
|
|
HunkTrackerSnapshot, HunkTurnDelta, SessionSummary, TrackingMode,
|
|
};
|
|
|
|
/// Commands sent to the HunkTrackerActor via mpsc channel.
|
|
#[derive(Debug)]
|
|
pub enum HunkTrackerCommand {
|
|
// === Mutation Commands (fire-and-forget) ===
|
|
/// Agent tool wrote to a file - record it and compute hunks
|
|
RecordAgentWrite {
|
|
path: PathBuf,
|
|
content: String,
|
|
prompt_index: usize,
|
|
/// Content of the file before this write (if known).
|
|
/// Used as a fallback baseline when the file doesn't exist in git HEAD
|
|
/// (e.g., in worktrees created from dirty state).
|
|
previous_content: Option<String>,
|
|
},
|
|
|
|
/// fs_notify detected a file change - check if we should track/update
|
|
HandleFileChange { path: PathBuf },
|
|
|
|
/// fs_notify detected file deletion
|
|
HandleFileDeleted { path: PathBuf },
|
|
|
|
/// Refresh git dirty cache (called periodically)
|
|
RefreshGitDirtyCache,
|
|
|
|
/// Reset baseline after commit
|
|
ResetBaseline { path: PathBuf },
|
|
|
|
/// Set tracking mode
|
|
SetMode { mode: TrackingMode },
|
|
|
|
// === Action Commands (accept/reject hunks) ===
|
|
/// Apply action (accept/reject) to a specific hunk
|
|
HunkAction {
|
|
hunk_id: HunkId,
|
|
action: HunkAction,
|
|
reply: oneshot::Sender<Result<(), HunkActionError>>,
|
|
},
|
|
|
|
/// Apply action (accept/reject) to all hunks for a file
|
|
FileAction {
|
|
path: PathBuf,
|
|
action: HunkAction,
|
|
reply: oneshot::Sender<Result<Vec<HunkId>, HunkActionError>>,
|
|
},
|
|
|
|
/// Apply action (accept/reject) to all hunks
|
|
AllAction {
|
|
action: HunkAction,
|
|
reply: oneshot::Sender<Result<Vec<HunkId>, HunkActionError>>,
|
|
},
|
|
|
|
/// Apply action (accept/reject) to all hunks for a specific turn
|
|
TurnAction {
|
|
prompt_index: usize,
|
|
action: HunkAction,
|
|
reply: oneshot::Sender<Result<Vec<HunkId>, HunkActionError>>,
|
|
},
|
|
|
|
// === Query Commands (request-response via oneshot) ===
|
|
/// Get all current hunks
|
|
GetAllHunks {
|
|
reply: oneshot::Sender<Vec<Arc<Hunk>>>,
|
|
},
|
|
|
|
/// Get hunks for a specific path
|
|
GetHunksForPath {
|
|
path: PathBuf,
|
|
reply: oneshot::Sender<Vec<Arc<Hunk>>>,
|
|
},
|
|
|
|
/// Get hunks + file content for a specific path (for diff rendering)
|
|
GetFileHunkData {
|
|
path: PathBuf,
|
|
reply: oneshot::Sender<FileHunkData>,
|
|
},
|
|
|
|
/// Get hunks filtered by source
|
|
GetHunksBySource {
|
|
source: HunkSourceFilter,
|
|
reply: oneshot::Sender<Vec<Arc<Hunk>>>,
|
|
},
|
|
|
|
/// Get a specific hunk by ID
|
|
GetHunk {
|
|
hunk_id: HunkId,
|
|
reply: oneshot::Sender<Option<Arc<Hunk>>>,
|
|
},
|
|
|
|
/// Check if a path is being tracked as an agent file
|
|
IsAgentFile {
|
|
path: PathBuf,
|
|
reply: oneshot::Sender<bool>,
|
|
},
|
|
|
|
/// Get all tracked file paths (agent + external, regardless of hunk state)
|
|
GetAllTrackedPaths {
|
|
reply: oneshot::Sender<Vec<PathBuf>>,
|
|
},
|
|
|
|
/// Get staged file paths (HEAD→index changes from git). Repo-wide in
|
|
/// AllDirty; scoped to tracked paths in AgentOnly.
|
|
GetStagedFiles {
|
|
reply: oneshot::Sender<HashSet<PathBuf>>,
|
|
},
|
|
|
|
/// Get baseline, current content, agent flag, and staged flag for every
|
|
/// tracked file in a single in-memory iteration. No async I/O.
|
|
GetAllFileContents {
|
|
reply: oneshot::Sender<Vec<FileContentEntry>>,
|
|
},
|
|
|
|
// === Session Summary Commands ===
|
|
/// Get complete session summary (stats + pending turns)
|
|
GetSessionSummary {
|
|
reply: oneshot::Sender<SessionSummary>,
|
|
},
|
|
|
|
/// Get pending hunks for a specific turn
|
|
GetTurnHunks {
|
|
prompt_index: usize,
|
|
reply: oneshot::Sender<Vec<Arc<Hunk>>>,
|
|
},
|
|
|
|
/// Reset session stats (e.g., after commit)
|
|
ResetStats,
|
|
|
|
/// Refresh all baselines from the current git HEAD and re-read current
|
|
/// content from disk. Used after a git HEAD/index change to reconcile stale state.
|
|
RefreshAllBaselines,
|
|
|
|
// === Snapshot / Restore Commands (for cross-session sync-back) ===
|
|
/// Take a snapshot of all hunk tracker state for preservation across
|
|
/// session kill/reload cycles.
|
|
SnapshotState {
|
|
reply: oneshot::Sender<HunkTrackerSnapshot>,
|
|
},
|
|
|
|
/// Incremental single-turn delta for the rewind checkpoint store.
|
|
SnapshotTurnDelta {
|
|
prompt_index: usize,
|
|
reply: oneshot::Sender<HunkTurnDelta>,
|
|
},
|
|
|
|
/// Restore a previously snapshotted state. Replaces all current file
|
|
/// states, turn index, and session stats.
|
|
RestoreState(HunkTrackerSnapshot),
|
|
}
|