§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:
ZacharyZhang-NY committed 2026-07-18 02:48:46 -04:00
1 parent 86e3724310
commit 6f31415ed6
1056 files changed
+8410 -18307

No files matched your search

+13 -13
View File
@@ -22,9 +22,9 @@ pub mod field {
pub const PATTERN: &str = "pattern";
}
/// The single `_meta` key holding the canonical tool identity as one nested
/// object (mirroring `x.ai/mcp_tool`). Consumers deserialize it into
/// object (mirroring `kigi/mcp_tool`). Consumers deserialize it into
/// [`CanonicalToolMeta`].
pub const TOOL_META_KEY: &str = "x.ai/tool";
pub const TOOL_META_KEY: &str = "kigi/tool";
/// Version of the canonical tool `_meta` contract. Bump on any breaking change
/// to keys or value shapes so consumers can adapt.
pub const TOOL_META_VERSION: u32 = 1;
@@ -33,7 +33,7 @@ impl ToolKind {
/// function of the kind, so equivalent tools across toolsets share it
/// (`read_file` and `Read` → `Read`; `run_terminal_cmd` and `Shell` →
/// `Run Command`). Display only; the model's tool name is `name` in
/// `x.ai/tool`. Exhaustive, so a new `ToolKind` must add a label to compile.
/// `kigi/tool`. Exhaustive, so a new `ToolKind` must add a label to compile.
pub fn presentation_name(self) -> &'static str {
match self {
ToolKind::Read => "Read",
@@ -140,11 +140,11 @@ pub struct ToolIdentity {
/// as one nested object under [`TOOL_META_KEY`].
///
/// ```json
/// "x.ai/tool": {
/// "kigi/tool": {
/// "version": 1,
/// "name": "read_file",
/// "kind": "read",
/// "namespace": "grok_build",
/// "namespace": "kigi",
/// "label": "Read",
/// "read_only": true,
/// "input": { "path": "..." }
@@ -153,7 +153,7 @@ pub struct ToolIdentity {
///
/// Consumer contract:
/// - **`label`** is the cross-harness grouping/display key: equivalent tools
/// share it (grok `read_file` → `"Read"`).
/// share it (kigi `read_file` → `"Read"`).
/// - **`kind`** is a finer discriminator (`metadata.kind()`), *not* guaranteed
/// equal for equivalent ops across harnesses (listing is `list` in one
/// toolset, `list_dir` in another); prefer `label` to join, tolerate unknowns.
@@ -176,7 +176,7 @@ pub struct ToolIdentity {
/// `namespace` is a closed enum (no `other` sink), so a new toolset fails
/// strict typed deserialization of the whole envelope — intentional, to force
/// typed consumers with exhaustive matches to update. Out-of-tree consumers
/// should read `namespace` loosely (as a string) and, on any `x.ai/tool`
/// should read `namespace` loosely (as a string) and, on any `kigi/tool`
/// parse failure, treat it as absent and fall back to `raw_input` + the ACP
/// `kind`. `version` bumps only on removal or meaning change.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, schemars::JsonSchema)]
@@ -209,7 +209,7 @@ impl CanonicalToolMeta {
}
}
/// Attach under [`TOOL_META_KEY`], preserving existing `_meta` keys
/// (`bash_mode`, `backend`, `x.ai/mcp_tool`, …).
/// (`bash_mode`, `backend`, `kigi/mcp_tool`, …).
pub fn merge_into(&self, existing: Option<serde_json::Value>) -> serde_json::Value {
debug_assert!(
matches!(existing, None | Some(serde_json::Value::Object(_))),
@@ -237,7 +237,7 @@ mod tests {
fn identity(kind: ToolKind) -> ToolIdentity {
ToolIdentity {
tool_kind: kind,
namespace: ToolNamespace::GrokBuild,
namespace: ToolNamespace::Kigi,
presentation_name: kind.presentation_name(),
read_only: kind.is_read_only(),
}
@@ -256,9 +256,9 @@ mod tests {
use strum::IntoEnumIterator;
fn wire_and_pascal(ns: ToolNamespace) -> (&'static str, &'static str) {
match ns {
ToolNamespace::GrokBuild => ("grok_build", "GrokBuild"),
ToolNamespace::GrokBuildConcise => ("grok_build_concise", "GrokBuildConcise"),
ToolNamespace::GrokBuildHashline => ("grok_build_hashline", "GrokBuildHashline"),
ToolNamespace::Kigi => ("kigi", "Kigi"),
ToolNamespace::KigiConcise => ("kigi_concise", "KigiConcise"),
ToolNamespace::KigiHashline => ("kigi_hashline", "KigiHashline"),
ToolNamespace::Codex => ("codex", "Codex"),
ToolNamespace::OpenCode => ("opencode", "OpenCode"),
ToolNamespace::MCP => ("mcp", "MCP"),
@@ -309,7 +309,7 @@ mod tests {
assert_eq!(t["version"], serde_json::json!(TOOL_META_VERSION));
assert_eq!(t["name"], "read_file");
assert_eq!(t["kind"], "read");
assert_eq!(t["namespace"], "grok_build");
assert_eq!(t["namespace"], "kigi");
assert_eq!(t["label"], "Read");
assert_eq!(t["read_only"], true);
assert_eq!(t["input"]["path"], "/a");