§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:
@@ -0,0 +1,115 @@
|
||||
//! `lsp` tool - code intelligence via language servers.
|
||||
//!
|
||||
//! Implementation is in `implementations::lsp`. This module provides the
|
||||
//! `LspTool` (Tool trait impl) under the `Kigi` namespace.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::implementations::lsp::{LspBackend, LspToolInput};
|
||||
use crate::types::output::ToolOutput;
|
||||
use crate::types::tool::{ToolKind, ToolNamespace};
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct LspToolOutput(pub String);
|
||||
|
||||
impl kigi_tool_runtime::ToolOutput for LspToolOutput {}
|
||||
|
||||
impl From<LspToolOutput> for ToolOutput {
|
||||
fn from(o: LspToolOutput) -> Self {
|
||||
ToolOutput::Text(o.0.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LspTool;
|
||||
|
||||
impl crate::types::tool_metadata::ToolMetadata for LspTool {
|
||||
fn kind(&self) -> ToolKind {
|
||||
ToolKind::Lsp
|
||||
}
|
||||
|
||||
fn tool_namespace(&self) -> ToolNamespace {
|
||||
ToolNamespace::Kigi
|
||||
}
|
||||
|
||||
fn description_template(&self) -> &str {
|
||||
r#"Code intelligence via language servers.${%- if tools.by_kind.search and tools.by_kind.read %} Prefer over ${{ tools.by_kind.search }}/${{ tools.by_kind.read }} for understanding code.${%- endif %}
|
||||
Operations: goToDefinition (jump to where a symbol is defined), findReferences (all usages of a symbol), hover (type info/docs at a position), goToImplementation (trait/interface implementations), documentSymbol (list all symbols in a file), workspaceSymbol (search symbols by name across the workspace — requires query parameter, not file_path).
|
||||
Requires file_path + line + character for position-based operations."#
|
||||
}
|
||||
|
||||
fn emitted_notifications(&self) -> &'static [&'static str] {
|
||||
&[
|
||||
"LspServerCrashed",
|
||||
"LspServerFailed",
|
||||
"LspServerReady",
|
||||
"LspServerRetrying",
|
||||
"LspServerStarting",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl kigi_tool_runtime::Tool for LspTool {
|
||||
type Args = LspToolInput;
|
||||
type Output = LspToolOutput;
|
||||
|
||||
fn id(&self) -> kigi_tool_protocol::ToolId {
|
||||
kigi_tool_protocol::ToolId::new("lsp").expect("valid tool id")
|
||||
}
|
||||
|
||||
fn description(
|
||||
&self,
|
||||
_ctx: &::kigi_tool_runtime::ListToolsContext,
|
||||
) -> kigi_tool_types::ToolDescription {
|
||||
kigi_tool_types::ToolDescription::new(
|
||||
"lsp",
|
||||
crate::types::tool_metadata::ToolMetadata::description_template(self),
|
||||
)
|
||||
}
|
||||
|
||||
fn capabilities(&self) -> kigi_tool_protocol::ToolCapabilities {
|
||||
kigi_tool_protocol::ToolCapabilities {
|
||||
is_read_only: true,
|
||||
tool_scope: Some(kigi_tool_protocol::ToolScope::Read),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
name = "tool.lsp",
|
||||
skip_all,
|
||||
fields(operation = %input.operation)
|
||||
)]
|
||||
async fn run(
|
||||
&self,
|
||||
ctx: kigi_tool_runtime::ToolCallContext,
|
||||
input: LspToolInput,
|
||||
) -> Result<LspToolOutput, kigi_tool_runtime::ToolError> {
|
||||
use crate::types::tool_metadata::shared_resources;
|
||||
let resources = shared_resources(&ctx)?;
|
||||
|
||||
let handle;
|
||||
{
|
||||
let res = resources.lock().await;
|
||||
handle = res
|
||||
.get::<Arc<dyn LspBackend>>()
|
||||
.ok_or_else(|| {
|
||||
kigi_tool_runtime::ToolError::custom(
|
||||
"process_manager",
|
||||
"LSP tool is unavailable. Configure ~/.kigi/lsp.json or <cwd>/.kigi/lsp.json and ensure the language server can start.",
|
||||
)
|
||||
})?
|
||||
.clone();
|
||||
}
|
||||
|
||||
let result = handle.dispatch(&input).await;
|
||||
if result.is_error {
|
||||
Err(kigi_tool_runtime::ToolError::custom(
|
||||
"process_manager",
|
||||
result.text,
|
||||
))
|
||||
} else {
|
||||
Ok(LspToolOutput(result.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user