§9 acceptance: grep-zero sweep — every internal x.ai/grok identifier renamed
The PRD's first acceptance gate now holds: grep -RinE '\bx\.ai\b|grok' crates/ --include='*.rs' → 0 matches (exempt: NOTICE and third-party license archives, README provenance, and the required 'Based on Grok Build Open Source' attribution, now sourced from version_attribution.txt). Wire-visible renames (both sides in this repo, changed in lockstep): - Auth method id 'grok.com' → 'kimi-code' (AuthMethodKind::KimiCode). - Every x.ai/* and _x.ai/* ACP ext method and meta key → kigi/* / _kigi/* (~200 names; grokShell → kigiShell). Session-file replay keeps a read-side alias for the legacy '_x.ai/session/update' method so existing updates.jsonl histories load; writes emit only the new name (both directions test-pinned). - Agent types grok-build* → kigi* with a documented legacy-prefix alias at resolution time so persisted sessions keep resolving. - ToolNamespace/BuiltinAgentName GrokBuild* → Kigi* (wire snake_case kigi/kigi_concise/kigi_hashline; schema regenerated); grok_build implementation dirs renamed to kigi*. - x-grok-* headers → x-kigi-*, __GROK_* sentinels → __KIGI_*, themes grokday/groknight → kigiday/kiginight (old persisted values fall back to the default theme), web_fetch allowlist xAI hosts → kimi.com + moonshot platforms, changelog CDN → this repo, grok-build changelog archives deleted. - BYOK default endpoint removed: [endpoints] api_base_url is now truly optional with NO default — consumers fail fast with the flag name when unset (no silent x.ai egress). Mock harnesses inject it explicitly. - System-prompt identity fixed: 'released by xAI' → 'an unofficial community CLI for Kimi' (template + regenerated encrypted form). Also repaired pre-existing grok-era test debt found by the sweep: the stale trace_classify default-model pin, the grok-pager UA label test, pty-harness stale-binary reuse and non-hermetic moonshot routing (a PTY test could previously reach the real api.moonshot.cn), and the outdated oauth fixture scope key. Gates: §9 grep 0; fmt clean; workspace check/clippy 0/0 (-D warnings); FULL cargo test --workspace: 234 suites, 21,961 passed, 0 failed; deny advisories ok.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Compacted-history assembly (grok-build's rebuild structure, generic).
|
||||
//! Compacted-history assembly (kigi's rebuild structure, generic).
|
||||
//!
|
||||
//! Moved from `kigi-chat-state::compaction_utils::build_compacted_history` and
|
||||
//! made generic over a write-side item factory so any harness can assemble
|
||||
@@ -8,7 +8,7 @@
|
||||
//! [SP, UP', AGENTS_MD?, UQ_last?, recent…, summary, reminder?]
|
||||
//! ```
|
||||
//!
|
||||
//! grok-build is the canonical harness. The summary carrier text is built by
|
||||
//! kigi is the canonical harness. The summary carrier text is built by
|
||||
//! [`super::summary::format_compact_summary_content`].
|
||||
|
||||
use crate::item::CompactionItemFactory;
|
||||
@@ -80,7 +80,7 @@ pub fn assemble_compacted_history<T: CompactionItemFactory>(
|
||||
compacted.push(T::new_user(wrap_user_query(last_query.as_str())));
|
||||
}
|
||||
|
||||
// grok-build keeps the legacy `<user_query>`-wrapped continuation text and
|
||||
// kigi keeps the legacy `<user_query>`-wrapped continuation text and
|
||||
// appends the transcript hint after the continuation summary.
|
||||
let mut formatted_summary = format_compact_summary_content(&parts.compaction_summary);
|
||||
if let Some(ref hint) = parts.transcript_hint {
|
||||
@@ -145,7 +145,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grok_build_order_recent_before_summary() {
|
||||
fn kigi_order_recent_before_summary() {
|
||||
let recent = vec![MockItem::Recent("a1".into()), MockItem::Recent("t1".into())];
|
||||
let out = assemble_compacted_history(parts(recent));
|
||||
// [sys, prefix, agents_md, query, a1, t1, summary, reminder]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! grok-build's full-replace compaction pass.
|
||||
//! kigi's full-replace compaction pass.
|
||||
//!
|
||||
//! grok-build does not select a tail to keep; it summarizes the whole
|
||||
//! kigi does not select a tail to keep; it summarizes the whole
|
||||
//! conversation and rebuilds a fresh history from scratch. This module is the
|
||||
//! transport-agnostic orchestration of that pass:
|
||||
//!
|
||||
@@ -41,7 +41,7 @@ pub struct FullReplaceContext<T> {
|
||||
/// The last real user query (raw), kept verbatim post-compaction.
|
||||
pub last_user_query: Option<String>,
|
||||
/// Working tail retained verbatim (tool/subagent results from the current
|
||||
/// turn). grok-build keeps this; pass empty to drop it.
|
||||
/// turn). kigi keeps this; pass empty to drop it.
|
||||
pub recent_messages: Vec<T>,
|
||||
/// Pre-rendered `<system-reminder>` (edited files, running tasks,
|
||||
/// subagents, MCP, …). The harness builds this; we only carry it.
|
||||
@@ -99,7 +99,7 @@ pub struct FullReplaceOutput<T> {
|
||||
|
||||
/// A successful full-replace **sampling** pass (summary only, no assembly).
|
||||
///
|
||||
/// Returned by [`sample_full_replace_summary`] for harnesses (grok-build's
|
||||
/// Returned by [`sample_full_replace_summary`] for harnesses (kigi's
|
||||
/// shell) that drive the input ladder and assemble the history themselves —
|
||||
/// they build the assembly inputs (state-context system-reminder, AGENTS.md,
|
||||
/// plan-mode) *after* the LLM call, so they cannot use the bundled
|
||||
@@ -111,7 +111,7 @@ pub struct FullReplaceSummary {
|
||||
pub attempts: u32,
|
||||
}
|
||||
|
||||
/// Run grok-build's full-replace compaction pass and return the rebuilt
|
||||
/// Run kigi's full-replace compaction pass and return the rebuilt
|
||||
/// history. Pure orchestration: no triggers, no persistence, no commit.
|
||||
///
|
||||
/// - `llm_turns` — the (harness-prepared/sanitized) conversation the model
|
||||
@@ -172,7 +172,7 @@ where
|
||||
/// and report every attempt through `observer`. Returns the raw summary; the
|
||||
/// caller assembles the history (and owns the input ladder).
|
||||
///
|
||||
/// This is the seam grok-build's shell uses: it drives the verbatim → fitted →
|
||||
/// This is the seam kigi's shell uses: it drives the verbatim → fitted →
|
||||
/// lossy input ladder around this call (stepping on a
|
||||
/// [`FullReplaceError::Sampler`] with `context_overflow = true`) and assembles
|
||||
/// the compacted history afterward from inputs it gathers post-sampling.
|
||||
@@ -193,7 +193,7 @@ where
|
||||
}
|
||||
|
||||
let prompt = CompactionPrompt {
|
||||
// grok-build appends the summarization prompt as the final user
|
||||
// kigi appends the summarization prompt as the final user
|
||||
// message; there is no separate system prompt for the compaction call.
|
||||
system: String::new(),
|
||||
user: build_summary_prompt(user_context),
|
||||
@@ -366,11 +366,11 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Golden end-to-end test: a realistic conversation + a mock sampler that
|
||||
/// returns a structured summary must produce grok-build's exact compacted
|
||||
/// returns a structured summary must produce kigi's exact compacted
|
||||
/// history shape, with the LLM output cleaned and the agent-state reminder
|
||||
/// carried through as the final item.
|
||||
#[tokio::test]
|
||||
async fn full_replace_produces_grok_build_history_shape() {
|
||||
async fn full_replace_produces_kigi_history_shape() {
|
||||
let llm_turns = vec![
|
||||
MockItem::System("you are a helpful assistant".into()),
|
||||
MockItem::User("fix the login bug".into()),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! grok-build compaction configuration.
|
||||
//! kigi compaction configuration.
|
||||
//!
|
||||
//! Holds the [`FullReplaceConfig`] tunables struct (mirroring
|
||||
//! [`IntraCompactionConfig`](crate::intra_compaction::IntraCompactionConfig) /
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
/// Default auto-compact threshold (% of context window) when no other source
|
||||
/// (env var, user config, remote per-model/global flags) sets it. Shared by
|
||||
/// grok-build and Grok chat (~85% trigger on both sides).
|
||||
/// kigi and Kigi chat (~85% trigger on both sides).
|
||||
pub const DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT: u8 = 85;
|
||||
|
||||
/// Minimum character count for a cleaned summary seed.
|
||||
///
|
||||
/// grok-build retries when the cleaned summary is shorter than this — the
|
||||
/// kigi retries when the cleaned summary is shorter than this — the
|
||||
/// smallest healthy prod summary observed was ~3,242 chars; anything under
|
||||
/// 500 is treated as degenerate and retried like a transient failure.
|
||||
pub const MIN_SUMMARY_SEED_CHARS: usize = 500;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! LLM calls.
|
||||
//!
|
||||
//! The *policy* lives here (shared across harnesses); the per-harness error
|
||||
//! types and their wrapping (e.g. grok-build's `SamplingError` →
|
||||
//! types and their wrapping (e.g. kigi's `SamplingError` →
|
||||
//! `CompactFailure(acp::Error)`) stay in thin host wrappers that delegate the
|
||||
//! status/message decisions to these functions.
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//! grok-build's "code agent" compaction subsystem.
|
||||
//! kigi's "code agent" compaction subsystem.
|
||||
//!
|
||||
//! grok-build does not select a tail to keep; it summarizes the whole
|
||||
//! kigi does not select a tail to keep; it summarizes the whole
|
||||
//! conversation and rebuilds a fresh history from scratch (the *full-replace*
|
||||
//! strategy). This module groups that subsystem — generic over the engine's
|
||||
//! [`CompactionItem`](crate::item::CompactionItem) /
|
||||
//! [`CompactionItemFactory`](crate::item::CompactionItemFactory) seams — so it
|
||||
//! can be reused as a unit by grok-build, separate from Grok chat's
|
||||
//! can be reused as a unit by kigi, separate from Kigi chat's
|
||||
//! [`intra_compaction`](crate::intra_compaction) (tail-keep, per-step) and
|
||||
//! [`inter_compaction`](crate::inter_compaction) (chunked, between-turn).
|
||||
//!
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//! Observability seam for the full-replace (grok-build) pass.
|
||||
//! Observability seam for the full-replace (kigi) pass.
|
||||
//!
|
||||
//! The shared orchestrator reports per-attempt and terminal outcomes through
|
||||
//! this trait so each harness can emit its own telemetry (grok-build:
|
||||
//! this trait so each harness can emit its own telemetry (kigi:
|
||||
//! `CompactionAttempt` rows, `CompactionRetryDegraded` events, span records,
|
||||
//! request-artifact persistence) without the shared crate depending on a
|
||||
//! telemetry backend. Mirrors
|
||||
//! [`IntraCompactionObserver`](crate::intra_compaction::IntraCompactionObserver)
|
||||
//! / [`InterCompactionObserver`](crate::inter_compaction::InterCompactionObserver).
|
||||
//!
|
||||
//! Emission points are part of the behavior contract: the grok-build observer
|
||||
//! Emission points are part of the behavior contract: the kigi observer
|
||||
//! preserves the pre-migration `CompactionAttempt`/`CompactionRetryDegraded`
|
||||
//! semantics byte-for-byte.
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//! grok-build's session-level summarization prompt.
|
||||
//! kigi's session-level summarization prompt.
|
||||
//!
|
||||
//! Split out of the crate-root `prompt` module so grok-build's full-replace
|
||||
//! Split out of the crate-root `prompt` module so kigi's full-replace
|
||||
//! prompt lives alongside the rest of its [`code_compaction`](crate::code_compaction)
|
||||
//! subsystem. The Grok chat's step-level intra prompt
|
||||
//! subsystem. The Kigi chat's step-level intra prompt
|
||||
//! ([`format_compaction_prompt`](crate::prompt::format_compaction_prompt))
|
||||
//! stays at the crate root.
|
||||
|
||||
/// Build grok-build's session-level summarization prompt (no chat history).
|
||||
/// Build kigi's session-level summarization prompt (no chat history).
|
||||
///
|
||||
/// `user_context` is the optional `/compact <text>` user-provided context,
|
||||
/// spliced inline into the structured prompt. Ported verbatim from
|
||||
@@ -49,11 +49,11 @@ your response.
|
||||
/// The prompt is owned by the harness's [`CompactionSampler`] impl (it appends
|
||||
/// the prompt as the final user message before sampling), not by the shared
|
||||
/// orchestrator. This enum lets each harness select the right one in one place
|
||||
/// so the structured (grok-build) and short self-summary prompts stay
|
||||
/// so the structured (kigi) and short self-summary prompts stay
|
||||
/// shared instead of duplicated per harness.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SummaryPromptKind {
|
||||
/// grok-build's detailed, numbered-section summary prompt.
|
||||
/// kigi's detailed, numbered-section summary prompt.
|
||||
#[default]
|
||||
Structured,
|
||||
/// The short self-summarization prompt.
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
#[test]
|
||||
fn kind_structured_matches_build_summary_prompt() {
|
||||
// The Structured kind must be byte-identical to the legacy entry point
|
||||
// so routing through the selector never changes grok-build's prompt.
|
||||
// so routing through the selector never changes kigi's prompt.
|
||||
assert_eq!(
|
||||
build_summary_prompt_kind(SummaryPromptKind::Structured, None),
|
||||
build_summary_prompt(None)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! The shared bounded-retry summary-sampling loop.
|
||||
//!
|
||||
//! The canonical `sample → classify → retry` loop, used by **both** grok-build's
|
||||
//! The canonical `sample → classify → retry` loop, used by **both** kigi's
|
||||
//! full-replace pass ([`sample_full_replace_summary`](super::sample_full_replace_summary))
|
||||
//! and Grok chat's intra `Shared` summarizer
|
||||
//! and Kigi chat's intra `Shared` summarizer
|
||||
//! ([`apply_intra_compaction`](crate::intra_compaction::apply_intra_compaction)).
|
||||
//! Centralising it here removes the two near-identical copies that previously
|
||||
//! lived in `code_compaction::compact` and `intra_compaction::compact`.
|
||||
@@ -18,7 +18,7 @@
|
||||
//!
|
||||
//! The loop is *content-neutral*: callers build the prompt, map the structured
|
||||
//! [`SampleRetryError`] onto their own error type, and decide whether to clean
|
||||
//! the winning summary (grok-build cleans in its assembler; intra cleans via
|
||||
//! the winning summary (kigi cleans in its assembler; intra cleans via
|
||||
//! [`format_compact_summary`](super::format_compact_summary)). Per-attempt
|
||||
//! telemetry flows through the [`FullReplaceObserver`] seam; callers without
|
||||
//! per-attempt metrics (intra) pass `&()`.
|
||||
@@ -63,7 +63,7 @@ pub enum SampleRetryError {
|
||||
/// Whether re-sending the same input cannot help.
|
||||
deterministic: bool,
|
||||
/// Whether the failure was a context-length overflow (a deterministic
|
||||
/// signal the grok-build host uses to step down its input size).
|
||||
/// signal the kigi host uses to step down its input size).
|
||||
context_overflow: bool,
|
||||
/// Total attempts made.
|
||||
attempts: u32,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! Moved verbatim from `kigi-chat-state`'s `compaction_utils`. Covers:
|
||||
//!
|
||||
//! - cleaning the compaction model's raw output ([`format_compact_summary`]),
|
||||
//! - the grok-build continuation carrier ([`format_compact_summary_content`]),
|
||||
//! - the kigi continuation carrier ([`format_compact_summary_content`]),
|
||||
//! - the canonical `<user_query>` wrapping ([`wrap_user_query`]).
|
||||
|
||||
/// Clean the compaction model's raw output into the plain-text `Summary:`
|
||||
|
||||
Reference in New Issue
Block a user