§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,7 +1,7 @@
|
||||
//! Headless single-turn mode (`grok -p "prompt"`).
|
||||
//! Headless single-turn mode (`kigi -p "prompt"`).
|
||||
//!
|
||||
//! Runs the agent in-process via
|
||||
//! `spawn_grok_shell`, sends the ACP lifecycle (init → auth → session → prompt),
|
||||
//! `spawn_kigi_shell`, sends the ACP lifecycle (init → auth → session → prompt),
|
||||
//! streams text to stdout, and exits cleanly via `CancellationToken`.
|
||||
|
||||
use std::collections::HashSet;
|
||||
@@ -24,7 +24,7 @@ use kigi_shell::sampling::types::{
|
||||
use kigi_shell::util::config as cli_config;
|
||||
|
||||
use crate::acp::model_state::{EffortTokenError, ModelState};
|
||||
use crate::acp::spawn::spawn_grok_shell;
|
||||
use crate::acp::spawn::spawn_kigi_shell;
|
||||
use crate::client_identity::{HEADLESS_CLIENT_TYPE, PAGER_CLIENT_VERSION};
|
||||
|
||||
// ── Types ────────────────────────────────────────────────────────────────
|
||||
@@ -618,7 +618,7 @@ async fn open_session(
|
||||
let mut m = acp::Meta::new();
|
||||
m.insert("noReplay".into(), serde_json::Value::Bool(true));
|
||||
if let Some(true) = restore_code {
|
||||
m.insert("x.ai/restore_code".into(), serde_json::Value::Bool(true));
|
||||
m.insert("kigi/restore_code".into(), serde_json::Value::Bool(true));
|
||||
}
|
||||
Some(m)
|
||||
}),
|
||||
@@ -694,7 +694,7 @@ async fn fork_then_open(
|
||||
let parent_is_worktree = parent_session_is_worktree(parent_id, &write_cwd);
|
||||
let payload = fork_session_params(parent_id, &write_cwd, new_id, parent_is_worktree);
|
||||
let req = acp::ExtRequest::new(
|
||||
"x.ai/session/fork",
|
||||
"kigi/session/fork",
|
||||
serde_json::value::to_raw_value(&payload)
|
||||
.expect("serialize fork params")
|
||||
.into(),
|
||||
@@ -796,7 +796,7 @@ async fn apply_headless_model_and_effort(
|
||||
.map_err(|e| {
|
||||
if let Some(name) = model_name {
|
||||
anyhow::anyhow!(
|
||||
"Couldn't set model '{}': {}. Run 'grok models' to see available models.",
|
||||
"Couldn't set model '{}': {}. Run 'kigi models' to see available models.",
|
||||
name,
|
||||
e
|
||||
)
|
||||
@@ -916,7 +916,7 @@ pub async fn run_single_turn(
|
||||
|
||||
let cancel = CancellationToken::new();
|
||||
let memory_config = agent_config.memory_config.clone();
|
||||
let spawned = match spawn_grok_shell(agent_config, &cancel, memory_config).await {
|
||||
let spawned = match spawn_kigi_shell(agent_config, &cancel, memory_config).await {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
let msg = format!("Couldn't start session: {e}");
|
||||
@@ -1121,9 +1121,9 @@ pub async fn run_single_turn(
|
||||
let mut ttf_logged = false;
|
||||
let mut prompt_fut = Box::pin(acp_send(request, &acp_tx));
|
||||
let mut prompt_result = None;
|
||||
// Pending background work: bash/monitor via x.ai/task_backgrounded +
|
||||
// Pending background work: bash/monitor via kigi/task_backgrounded +
|
||||
// task_completed; background subagents via SubagentSpawned + SubagentFinished
|
||||
// on x.ai/session_notification (prefixed `subagent:{id}` in pending_bg).
|
||||
// on kigi/session_notification (prefixed `subagent:{id}` in pending_bg).
|
||||
// Tracked regardless of wait_for_background so the exit reaper always
|
||||
// sees still-running work; the flag only gates waiting.
|
||||
// No idle/quiet polling and no wait for server-side auto-wake text — exit
|
||||
@@ -1336,13 +1336,13 @@ fn reap_request_for_key(
|
||||
) -> serde_json::Result<acp::ExtRequest> {
|
||||
let (method, params) = match key.strip_prefix("subagent:") {
|
||||
Some(id) => (
|
||||
"x.ai/subagent/cancel",
|
||||
"kigi/subagent/cancel",
|
||||
serde_json::value::to_raw_value(&CancelSubagentRequest {
|
||||
subagent_id: id.to_string(),
|
||||
})?,
|
||||
),
|
||||
None => (
|
||||
"x.ai/task/kill",
|
||||
"kigi/task/kill",
|
||||
serde_json::value::to_raw_value(&KillTaskRequest {
|
||||
session_id: session_id.0.to_string(),
|
||||
task_id: key.to_string(),
|
||||
@@ -1557,7 +1557,7 @@ fn handle_ext_notification(
|
||||
let method = notif.request.method.as_ref();
|
||||
|
||||
// Background task lifecycle uses dedicated methods (not session_notification).
|
||||
if method == "x.ai/task_backgrounded" {
|
||||
if method == "kigi/task_backgrounded" {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct TaskBgEnvelope {
|
||||
update: TaskBgUpdate,
|
||||
@@ -1587,7 +1587,7 @@ fn handle_ext_notification(
|
||||
return ExtEvent::None;
|
||||
}
|
||||
|
||||
if method == "x.ai/task_completed" {
|
||||
if method == "kigi/task_completed" {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct TaskDoneEnvelope {
|
||||
update: TaskDoneUpdate,
|
||||
@@ -1615,12 +1615,12 @@ fn handle_ext_notification(
|
||||
return ExtEvent::None;
|
||||
}
|
||||
|
||||
if method == "x.ai/monitor_event" {
|
||||
if method == "kigi/monitor_event" {
|
||||
return ExtEvent::MonitorEvent;
|
||||
}
|
||||
|
||||
match method {
|
||||
"x.ai/session_notification" | "x.ai/session/update" => {}
|
||||
"kigi/session_notification" | "kigi/session/update" => {}
|
||||
_ => return ExtEvent::None,
|
||||
}
|
||||
|
||||
@@ -1800,7 +1800,7 @@ mod tests {
|
||||
fn reap_request_for_task_kills_with_session_scope() {
|
||||
let session_id = acp::SessionId::new("sess-1");
|
||||
let request = super::reap_request_for_key("task-42", &session_id).unwrap();
|
||||
assert_eq!(request.method.as_ref(), "x.ai/task/kill");
|
||||
assert_eq!(request.method.as_ref(), "kigi/task/kill");
|
||||
let params: serde_json::Value = serde_json::from_str(request.params.get()).unwrap();
|
||||
assert_eq!(params["sessionId"], "sess-1");
|
||||
assert_eq!(params["taskId"], "task-42");
|
||||
@@ -1810,7 +1810,7 @@ mod tests {
|
||||
fn reap_request_for_subagent_cancels_with_stripped_id() {
|
||||
let session_id = acp::SessionId::new("sess-1");
|
||||
let request = super::reap_request_for_key("subagent:sub-7", &session_id).unwrap();
|
||||
assert_eq!(request.method.as_ref(), "x.ai/subagent/cancel");
|
||||
assert_eq!(request.method.as_ref(), "kigi/subagent/cancel");
|
||||
let params: serde_json::Value = serde_json::from_str(request.params.get()).unwrap();
|
||||
assert_eq!(params["subagentId"], "sub-7");
|
||||
}
|
||||
@@ -2009,10 +2009,10 @@ mod tests {
|
||||
#[test]
|
||||
fn headless_task_backgrounded_parses_task_id() {
|
||||
// `make_ext_notif` wraps the arg under `update`, so pass
|
||||
// the inner update object (matching the real `x.ai/task_backgrounded`
|
||||
// the inner update object (matching the real `kigi/task_backgrounded`
|
||||
// wire shape: `{ "update": { "sessionUpdate": ..., "task_id": ... } }`).
|
||||
let notif = make_ext_notif(
|
||||
"x.ai/task_backgrounded",
|
||||
"kigi/task_backgrounded",
|
||||
serde_json::json!({
|
||||
"sessionUpdate": "task_backgrounded",
|
||||
"task_id": "task-abc",
|
||||
@@ -2027,7 +2027,7 @@ mod tests {
|
||||
#[test]
|
||||
fn headless_task_backgrounded_with_monitor_description_is_monitor() {
|
||||
let notif = make_ext_notif(
|
||||
"x.ai/task_backgrounded",
|
||||
"kigi/task_backgrounded",
|
||||
serde_json::json!({
|
||||
"sessionUpdate": "task_backgrounded",
|
||||
"task_id": "mon-1",
|
||||
@@ -2048,7 +2048,7 @@ mod tests {
|
||||
// this test guards against a future `rename_all = "camelCase"` on
|
||||
// `TaskSnapshot` silently turning waiting into a no-op.
|
||||
let notif = make_ext_notif(
|
||||
"x.ai/task_completed",
|
||||
"kigi/task_completed",
|
||||
serde_json::json!({
|
||||
"sessionUpdate": "task_completed",
|
||||
"task_snapshot": { "task_id": "task-abc" }
|
||||
@@ -2063,7 +2063,7 @@ mod tests {
|
||||
#[test]
|
||||
fn headless_subagent_spawned_and_finished_parse() {
|
||||
let spawned = make_ext_notif(
|
||||
"x.ai/session_notification",
|
||||
"kigi/session_notification",
|
||||
serde_json::json!({
|
||||
"sessionUpdate": "subagent_spawned",
|
||||
"subagent_id": "sub-1",
|
||||
@@ -2078,7 +2078,7 @@ mod tests {
|
||||
ExtEvent::SubagentSpawned { subagent_id } if subagent_id == "sub-1"
|
||||
));
|
||||
let finished = make_ext_notif(
|
||||
"x.ai/session_notification",
|
||||
"kigi/session_notification",
|
||||
serde_json::json!({
|
||||
"sessionUpdate": "subagent_finished",
|
||||
"subagent_id": "sub-1",
|
||||
@@ -2107,7 +2107,7 @@ mod tests {
|
||||
let raw = serde_json::value::to_raw_value(&payload).unwrap();
|
||||
let (tx, _rx) = tokio::sync::oneshot::channel();
|
||||
let notif = kigi_acp_lib::AcpArgs {
|
||||
request: acp::ExtNotification::new("x.ai/other", raw.into()),
|
||||
request: acp::ExtNotification::new("kigi/other", raw.into()),
|
||||
response_tx: tx,
|
||||
}
|
||||
.boxed();
|
||||
|
||||
Reference in New Issue
Block a user