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,193 @@
|
||||
//! `/plan` -- enter plan mode.
|
||||
//!
|
||||
//! `/plan` enters plan mode. `/plan <description>` enters plan mode and starts
|
||||
//! a turn with the description after the mode switch completes.
|
||||
//!
|
||||
//! Use `/view-plan` to open the current saved plan preview.
|
||||
|
||||
use crate::app::actions::{Action, PlanModeKind};
|
||||
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
|
||||
|
||||
/// Enter plan mode.
|
||||
pub struct PlanCommand;
|
||||
|
||||
impl SlashCommand for PlanCommand {
|
||||
fn name(&self) -> &str {
|
||||
"plan"
|
||||
}
|
||||
|
||||
fn description(&self) -> &str {
|
||||
"Enter plan mode"
|
||||
}
|
||||
|
||||
fn session_scoped(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn offered_when_session_less(&self) -> bool {
|
||||
// The dashboard offers `/plan` to start the next spawned agent in
|
||||
// plan mode (intercepted in `dispatch_dashboard_dispatch_slash`).
|
||||
true
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"/plan [description]"
|
||||
}
|
||||
|
||||
fn takes_args(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn arg_placeholder(&self) -> Option<&str> {
|
||||
Some("[description]")
|
||||
}
|
||||
|
||||
fn run(&self, _ctx: &mut CommandExecCtx, args: &str) -> CommandResult {
|
||||
let trimmed = args.trim();
|
||||
if trimmed.is_empty() {
|
||||
return CommandResult::Action(Action::SetPlanMode(PlanModeKind::On));
|
||||
}
|
||||
CommandResult::Action(Action::EnterPlanMode {
|
||||
description: Some(trimmed.to_string()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::acp::model_state::ModelState;
|
||||
use crate::app::bundle::BundleState;
|
||||
use crate::settings::PagerLocalSnapshot;
|
||||
|
||||
fn make_ctx_inactive_plan_mode<'a>(
|
||||
models: &'a ModelState,
|
||||
bundle: &'a BundleState,
|
||||
) -> CommandExecCtx<'a> {
|
||||
CommandExecCtx {
|
||||
models,
|
||||
session_id: None,
|
||||
bundle_state: bundle,
|
||||
screen_mode: crate::app::ScreenMode::Inline,
|
||||
pager_state: PagerLocalSnapshot {
|
||||
plan_mode_active: false,
|
||||
..PagerLocalSnapshot::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn make_ctx_active_plan_mode<'a>(
|
||||
models: &'a ModelState,
|
||||
bundle: &'a BundleState,
|
||||
) -> CommandExecCtx<'a> {
|
||||
CommandExecCtx {
|
||||
models,
|
||||
session_id: None,
|
||||
bundle_state: bundle,
|
||||
screen_mode: crate::app::ScreenMode::Inline,
|
||||
pager_state: PagerLocalSnapshot {
|
||||
plan_mode_active: true,
|
||||
..PagerLocalSnapshot::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// `/plan` (no args, not in plan mode) → `SetPlanMode(On)`.
|
||||
#[test]
|
||||
fn no_args_not_in_plan_dispatches_set_plan_mode_on() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_inactive_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, "") {
|
||||
CommandResult::Action(Action::SetPlanMode(kind)) => {
|
||||
assert_eq!(
|
||||
kind,
|
||||
PlanModeKind::On,
|
||||
"`/plan` (no args, not in plan mode) must dispatch SetPlanMode(On)"
|
||||
);
|
||||
}
|
||||
other => panic!("expected Action::SetPlanMode, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `/plan` (no args, already in plan mode) → idempotent `SetPlanMode(On)`.
|
||||
#[test]
|
||||
fn no_args_already_in_plan_dispatches_set_plan_mode_on() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_active_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, "") {
|
||||
CommandResult::Action(Action::SetPlanMode(kind)) => {
|
||||
assert_eq!(kind, PlanModeKind::On);
|
||||
}
|
||||
other => panic!("expected Action::SetPlanMode, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whitespace-only → treated as no args.
|
||||
#[test]
|
||||
fn whitespace_only_arg_not_in_plan_dispatches_set_plan_mode_on() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_inactive_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, " ") {
|
||||
CommandResult::Action(Action::SetPlanMode(kind)) => {
|
||||
assert_eq!(kind, PlanModeKind::On);
|
||||
}
|
||||
other => panic!("expected SetPlanMode for whitespace-only arg, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `/plan <description>` → `EnterPlanMode` with description.
|
||||
#[test]
|
||||
fn with_description_keeps_enter_plan_mode_when_not_in_plan() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_inactive_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, "Refactor the auth flow") {
|
||||
CommandResult::Action(Action::EnterPlanMode { description }) => {
|
||||
assert_eq!(
|
||||
description.as_deref(),
|
||||
Some("Refactor the auth flow"),
|
||||
"`/plan <desc>` must dispatch EnterPlanMode with the description"
|
||||
);
|
||||
}
|
||||
other => panic!("expected Action::EnterPlanMode, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `/plan <description>` when already in plan mode still emits
|
||||
/// `EnterPlanMode`; the dispatcher owns the idempotent mode handling.
|
||||
#[test]
|
||||
fn with_description_already_in_plan_keeps_enter_plan_mode() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_active_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, "something") {
|
||||
CommandResult::Action(Action::EnterPlanMode { description }) => {
|
||||
assert_eq!(description.as_deref(), Some("something"));
|
||||
}
|
||||
other => panic!("expected EnterPlanMode, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whitespace is trimmed from the description.
|
||||
#[test]
|
||||
fn with_description_trims_whitespace() {
|
||||
let cmd = PlanCommand;
|
||||
let models = ModelState::default();
|
||||
let bundle = BundleState::default();
|
||||
let mut ctx = make_ctx_inactive_plan_mode(&models, &bundle);
|
||||
match cmd.run(&mut ctx, " hello world ") {
|
||||
CommandResult::Action(Action::EnterPlanMode { description }) => {
|
||||
assert_eq!(description.as_deref(), Some("hello world"));
|
||||
}
|
||||
other => panic!("expected EnterPlanMode, got {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user