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:
@@ -0,0 +1,5 @@
|
||||
//! Shared prompt-queue wire types for kigi-shell and kigi-tui.
|
||||
|
||||
mod types;
|
||||
|
||||
pub use types::{QueueChanged, QueueEntryMeta, QueueEntryWire};
|
||||
@@ -0,0 +1,171 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Per-item queue metadata the session actor attaches to user-originated inputs; synthetic
|
||||
/// inputs (auto-wake, nudges) carry none and never appear in the visible queue. Held in
|
||||
/// actor state, never serialized itself.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct QueueEntryMeta {
|
||||
/// Stable id, reusing the prompt's unique `prompt_id`.
|
||||
pub id: String,
|
||||
/// Monotonic, bumped on each in-place edit; an edit against a stale version is a no-op.
|
||||
pub version: u64,
|
||||
/// Enqueuing client identifier (attribution); never overwritten by edits.
|
||||
pub owner: Option<String>,
|
||||
/// Most recent editor's client identifier, replaced on every in-place edit.
|
||||
pub last_editor: Option<String>,
|
||||
/// Display kind label; client-cosmetic kinds resolve to their send-intent before enqueue.
|
||||
pub kind: String,
|
||||
/// Plain prompt text for the shared queue display.
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
/// One queue row on the wire.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct QueueEntryWire {
|
||||
pub id: String,
|
||||
#[serde(default)]
|
||||
pub version: u64,
|
||||
/// Omitted from the wire when `None`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub owner: Option<String>,
|
||||
/// Mirrors [`QueueEntryMeta::last_editor`]; omitted from the wire when `None`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub last_editor: Option<String>,
|
||||
#[serde(default)]
|
||||
pub kind: String,
|
||||
#[serde(default)]
|
||||
pub text: String,
|
||||
/// 0-based position among queued, not-yet-running prompts.
|
||||
#[serde(default)]
|
||||
pub position: usize,
|
||||
}
|
||||
|
||||
/// Broadcast payload for the `x.ai/queue/changed` notification.
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct QueueChanged {
|
||||
/// The session this queue belongs to; drives per-session fan-out routing.
|
||||
pub session_id: String,
|
||||
#[serde(default)]
|
||||
pub entries: Vec<QueueEntryWire>,
|
||||
/// The prompt the actor is currently draining, `None` when no turn runs. The correlation
|
||||
/// signal a subscriber uses to adopt `current_prompt_id` for notification routing.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub running_prompt_id: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn queue_changed_full_round_trip() {
|
||||
let original = QueueChanged {
|
||||
session_id: "sess-42".into(),
|
||||
entries: vec![
|
||||
QueueEntryWire {
|
||||
id: "p1".into(),
|
||||
version: 3,
|
||||
owner: Some("alice".into()),
|
||||
last_editor: Some("bob".into()),
|
||||
kind: "prompt".into(),
|
||||
text: "fix the bug".into(),
|
||||
position: 0,
|
||||
},
|
||||
QueueEntryWire {
|
||||
id: "p2".into(),
|
||||
version: 0,
|
||||
owner: None,
|
||||
last_editor: None,
|
||||
kind: "bash".into(),
|
||||
text: "ls -la".into(),
|
||||
position: 1,
|
||||
},
|
||||
],
|
||||
running_prompt_id: Some("p0".into()),
|
||||
};
|
||||
let json = serde_json::to_value(&original).unwrap();
|
||||
assert_eq!(json["sessionId"], "sess-42");
|
||||
assert_eq!(json["entries"][0]["lastEditor"], "bob");
|
||||
assert_eq!(json["runningPromptId"], "p0");
|
||||
assert!(json["entries"][1].get("owner").is_none());
|
||||
assert!(json["entries"][1].get("lastEditor").is_none());
|
||||
let round: QueueChanged = serde_json::from_value(json).unwrap();
|
||||
assert_eq!(round, original);
|
||||
}
|
||||
|
||||
/// Pins the exact wire JSON; a key rename here breaks deployed clients.
|
||||
#[test]
|
||||
fn queue_changed_golden_wire_json() {
|
||||
let payload = QueueChanged {
|
||||
session_id: "s1".into(),
|
||||
entries: vec![QueueEntryWire {
|
||||
id: "p1".into(),
|
||||
version: 2,
|
||||
owner: Some("alice".into()),
|
||||
last_editor: Some("bob".into()),
|
||||
kind: "prompt".into(),
|
||||
text: "hi".into(),
|
||||
position: 0,
|
||||
}],
|
||||
running_prompt_id: Some("p0".into()),
|
||||
};
|
||||
let expected = serde_json::json!({
|
||||
"sessionId": "s1",
|
||||
"entries": [{
|
||||
"id": "p1",
|
||||
"version": 2,
|
||||
"owner": "alice",
|
||||
"lastEditor": "bob",
|
||||
"kind": "prompt",
|
||||
"text": "hi",
|
||||
"position": 0
|
||||
}],
|
||||
"runningPromptId": "p0"
|
||||
});
|
||||
assert_eq!(serde_json::to_value(&payload).unwrap(), expected);
|
||||
}
|
||||
|
||||
/// A broadcast without sessionId must fail to parse, not apply under the wrong key.
|
||||
#[test]
|
||||
fn queue_changed_requires_session_id() {
|
||||
let missing = serde_json::json!({ "entries": [] });
|
||||
assert!(serde_json::from_value::<QueueChanged>(missing).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sparse_payload_deserializes_with_defaults() {
|
||||
let sparse = serde_json::json!({
|
||||
"sessionId": "s1",
|
||||
"entries": [{"id": "p1"}]
|
||||
});
|
||||
let parsed: QueueChanged = serde_json::from_value(sparse).unwrap();
|
||||
assert_eq!(parsed.entries[0].version, 0);
|
||||
assert_eq!(parsed.entries[0].kind, "");
|
||||
assert_eq!(parsed.entries[0].text, "");
|
||||
assert_eq!(parsed.entries[0].position, 0);
|
||||
assert!(parsed.entries[0].owner.is_none());
|
||||
assert!(parsed.running_prompt_id.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extra_unknown_fields_ignored() {
|
||||
let json = serde_json::json!({
|
||||
"sessionId": "s1",
|
||||
"entries": [],
|
||||
"runningPromptId": null,
|
||||
"futureField": "should be ignored"
|
||||
});
|
||||
let parsed: QueueChanged = serde_json::from_value(json).unwrap();
|
||||
assert_eq!(parsed.session_id, "s1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn queue_changed_derives_default() {
|
||||
let d = QueueChanged::default();
|
||||
assert_eq!(d.session_id, "");
|
||||
assert!(d.entries.is_empty());
|
||||
assert!(d.running_prompt_id.is_none());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user