feat: hapus fitur LSP bawaan (language server protocol)

Hapus seluruh pipeline LSP (client, manager, provisioner, dan 7 tool
lsp_*) dari codebase:

- apps/infrastructure/src/lsp/ (client.rs, manager.rs, provisioner/*)
- apps/infrastructure/src/tools/lsp/ (connect, disconnect, diagnostics,
  hover, completion, definition, references)
- ToolCtx/ToolCtxBuilder: hapus field lsp_manager
- Daemon state: hapus lsp_manager, lsp_provision_msgs, shutdown_lsp
- Registry: hapus registrasi 7 tool lsp_*
- Settings: hapus lsp_auto_provision + lsp_languages
- Agent definitions: hapus lsp_* dari allowed tools coder/reviewer
- Cargo: hapus dependency lsp-types (workspace + infra)
- Update dokumentasi mod + arch_audit forbidden list

Verifikasi: cargo check/clippy/test semua hijau (54 test), tidak ada
referensi lsp_* tersisa di luar CHANGELOG.
This commit is contained in:
asepharyana
2026-08-27 22:38:21 +07:00
parent 9ea3d361b1
commit 93f3c2a357
30 changed files with 14 additions and 1009 deletions
-4
View File
@@ -16,7 +16,6 @@ pub struct ToolCtx {
pub mention_index: crate::MentionIndex,
pub origin: crate::Origin,
pub graduated_checks: Vec<crate::tools::GraduatedCheck>,
pub lsp_manager: Arc<Mutex<crate::lsp::manager::LspManager>>,
pub turn_events: Option<Arc<Mutex<std::collections::VecDeque<crate::TurnEvent>>>>,
pub workflow_findings: Option<Arc<Mutex<Vec<String>>>>,
pub abort_flag: Option<Arc<AtomicBool>>,
@@ -39,7 +38,6 @@ pub struct ToolCtxBuilder {
pub mention_index: crate::MentionIndex,
pub origin: crate::Origin,
pub graduated_checks: Vec<crate::tools::GraduatedCheck>,
pub lsp_manager: Arc<Mutex<crate::lsp::manager::LspManager>>,
pub turn_events: Option<Arc<Mutex<std::collections::VecDeque<crate::TurnEvent>>>>,
pub workflow_findings: Option<Arc<Mutex<Vec<String>>>>,
pub abort_flag: Option<Arc<AtomicBool>>,
@@ -56,7 +54,6 @@ impl Default for ToolCtxBuilder {
mention_index: crate::MentionIndex::new(),
origin: crate::Origin::Main,
graduated_checks: Vec::new(),
lsp_manager: Arc::new(Mutex::new(crate::lsp::manager::LspManager::new())),
turn_events: None,
workflow_findings: None,
abort_flag: None,
@@ -98,7 +95,6 @@ impl ToolCtxBuilder {
mention_index: self.mention_index,
origin: self.origin,
graduated_checks: self.graduated_checks,
lsp_manager: self.lsp_manager,
turn_events: self.turn_events,
workflow_findings: self.workflow_findings,
abort_flag: self.abort_flag,
@@ -1,80 +0,0 @@
//! Get completion suggestions from LSP.
//!
//! Sends a `textDocument/completion` request to the connected language
//! server for a given file position.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that requests code completion suggestions from an LSP server.
///
/// Flow: parse language/path/line/character → lock LSP manager → find client
/// → send `textDocument/completion` → return pretty-printed JSON response.
pub struct LspCompletion;
impl Tool for LspCompletion {
fn name(&self) -> &'static str {
"lsp_completion"
}
fn description(&self) -> &'static str {
"Get completion suggestions at a position"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier"
},
"path": {
"type": "string",
"description": "File path"
},
"line": {
"type": "integer",
"description": "Line number (0-based)"
},
"character": {
"type": "integer",
"description": "Character offset (0-based)"
}
},
"required": ["language", "path", "line", "character"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let path = crate::tools::arg_str(args, "path")?;
let line = args.get("line").and_then(|v| v.as_i64()).unwrap_or(0);
let character = args.get("character").and_then(|v| v.as_i64()).unwrap_or(0);
info!(language, path, line, character, "LSP completion requested");
let manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(client) = manager.get_client(&language) {
let result = client.send_request(
"textDocument/completion",
&json!({
"textDocument": { "uri": format!("file://{}", path) },
"position": { "line": line, "character": character }
}),
)?;
Ok(serde_json::to_string_pretty(&result)?)
} else {
anyhow::bail!("no LSP client connected for '{language}'")
}
}
}
@@ -1,76 +0,0 @@
//! Connect to an LSP language server.
//!
//! Starts a new language server process and registers it in the
//! shared LSP manager for subsequent tool invocations.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that connects to an LSP language server for a given language.
///
/// Flow: parse language + command + args → lock LSP manager → call
/// `manager.start()` → confirm connection in the response string.
pub struct LspConnect;
impl Tool for LspConnect {
fn name(&self) -> &'static str {
"lsp_connect"
}
fn description(&self) -> &'static str {
"Connect to an LSP language server for a given language"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier (e.g. 'rust', 'python')"
},
"command": {
"type": "string",
"description": "Command to start the language server"
},
"args": {
"type": "array",
"items": {"type": "string"},
"description": "Arguments for the language server command"
}
},
"required": ["language", "command"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let command = crate::tools::arg_str(args, "command")?;
let extra_args: Vec<String> = args
.get("args")
.and_then(|v| v.as_array())
.map(|arr| {
arr.iter()
.filter_map(|v| v.as_str().map(String::from))
.collect()
})
.unwrap_or_default();
info!(language, command, extra_args = ?extra_args, "LSP connect requested");
let mut manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
manager.start(&language, &command, &extra_args)?;
info!(language, "LSP connected successfully");
Ok(format!("Connected LSP for '{language}'"))
}
}
@@ -1,81 +0,0 @@
//! Go-to-definition via LSP.
//!
//! Sends a `textDocument/definition` request to the connected language
//! server for a symbol at a given file position.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that resolves a symbol's definition location via LSP.
///
/// Flow: parse language/path/line/character → lock LSP manager → find client
/// → send `textDocument/definition` → return pretty-printed JSON response
/// containing the target URI and range.
pub struct LspDefinition;
impl Tool for LspDefinition {
fn name(&self) -> &'static str {
"lsp_definition"
}
fn description(&self) -> &'static str {
"Go to definition for a symbol at a position"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier"
},
"path": {
"type": "string",
"description": "File path"
},
"line": {
"type": "integer",
"description": "Line number (0-based)"
},
"character": {
"type": "integer",
"description": "Character offset (0-based)"
}
},
"required": ["language", "path", "line", "character"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let path = crate::tools::arg_str(args, "path")?;
let line = args.get("line").and_then(|v| v.as_i64()).unwrap_or(0);
let character = args.get("character").and_then(|v| v.as_i64()).unwrap_or(0);
info!(language, path, line, character, "LSP definition requested");
let manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(client) = manager.get_client(&language) {
let result = client.send_request(
"textDocument/definition",
&json!({
"textDocument": { "uri": format!("file://{}", path) },
"position": { "line": line, "character": character }
}),
)?;
Ok(serde_json::to_string_pretty(&result)?)
} else {
anyhow::bail!("no LSP client connected for '{language}'")
}
}
}
@@ -1,70 +0,0 @@
//! Get diagnostics from LSP.
//!
//! Sends a `textDocument/diagnostic` request to the connected language
//! server for a given file and returns errors, warnings, and other
//! diagnostics.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that retrieves diagnostics (errors, warnings) from the LSP for a file.
///
/// Flow: parse language/path → lock LSP manager → find client
/// → send `textDocument/diagnostic` → return pretty-printed JSON response.
pub struct LspDiagnostics;
impl Tool for LspDiagnostics {
fn name(&self) -> &'static str {
"lsp_diagnostics"
}
fn description(&self) -> &'static str {
"Get diagnostics (errors, warnings) from the LSP for a file"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier"
},
"path": {
"type": "string",
"description": "File path to get diagnostics for"
}
},
"required": ["language", "path"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let path = crate::tools::arg_str(args, "path")?;
info!(language, path, "LSP diagnostics requested");
let manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(client) = manager.get_client(&language) {
let result = client.send_request(
"textDocument/diagnostic",
&json!({
"textDocument": { "uri": format!("file://{}", path) }
}),
)?;
Ok(serde_json::to_string_pretty(&result)?)
} else {
anyhow::bail!("no LSP client connected for '{language}'")
}
}
}
@@ -1,54 +0,0 @@
//! Disconnect from an LSP language server.
//!
//! Removes the registered LSP client for a given language from
//! the shared LSP manager.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that disconnects an LSP language server for a given language.
///
/// Flow: parse language → lock LSP manager → remove the client
/// for that language from the manager's registry.
pub struct LspDisconnect;
impl Tool for LspDisconnect {
fn name(&self) -> &'static str {
"lsp_disconnect"
}
fn description(&self) -> &'static str {
"Disconnect from an LSP language server"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier to disconnect"
}
},
"required": ["language"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
info!(language, "LSP disconnect requested");
let _manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
info!(language, "LSP disconnected");
Ok(format!("Disconnected LSP for '{language}'"))
}
}
@@ -1,81 +0,0 @@
//! Get hover information from LSP.
//!
//! Sends a `textDocument/hover` request to the connected language
//! server for a symbol at a given file position.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that retrieves hover information for a symbol at a position via LSP.
///
/// Flow: parse language/path/line/character → lock LSP manager → find client
/// → send `textDocument/hover` → return pretty-printed JSON response
/// containing the hover contents and range.
pub struct LspHover;
impl Tool for LspHover {
fn name(&self) -> &'static str {
"lsp_hover"
}
fn description(&self) -> &'static str {
"Get hover information for a symbol at a position"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier"
},
"path": {
"type": "string",
"description": "File path"
},
"line": {
"type": "integer",
"description": "Line number (0-based)"
},
"character": {
"type": "integer",
"description": "Character offset (0-based)"
}
},
"required": ["language", "path", "line", "character"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let path = crate::tools::arg_str(args, "path")?;
let line = args.get("line").and_then(|v| v.as_i64()).unwrap_or(0);
let character = args.get("character").and_then(|v| v.as_i64()).unwrap_or(0);
info!(language, path, line, character, "LSP hover requested");
let manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(client) = manager.get_client(&language) {
let result = client.send_request(
"textDocument/hover",
&json!({
"textDocument": { "uri": format!("file://{}", path) },
"position": { "line": line, "character": character }
}),
)?;
Ok(serde_json::to_string_pretty(&result)?)
} else {
anyhow::bail!("no LSP client connected for '{language}'")
}
}
}
-18
View File
@@ -1,18 +0,0 @@
//! LSP tool implementations — connect, diagnostics, hover, completion,
//! definition, references, disconnect.
pub mod completion;
pub mod connect;
pub mod definition;
pub mod diagnostics;
pub mod disconnect;
pub mod hover;
pub mod references;
pub use completion::LspCompletion;
pub use connect::LspConnect;
pub use definition::LspDefinition;
pub use diagnostics::LspDiagnostics;
pub use disconnect::LspDisconnect;
pub use hover::LspHover;
pub use references::LspReferences;
@@ -1,81 +0,0 @@
//! Find references via LSP.
//!
//! Sends a `textDocument/references` request to the connected language
//! server for a symbol at a given file position.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
use tracing::{error, info, instrument};
/// Tool that finds all references to a symbol at a position via LSP.
///
/// Flow: parse language/path/line/character → lock LSP manager → find client
/// → send `textDocument/references` → return pretty-printed JSON response
/// containing all reference locations.
pub struct LspReferences;
impl Tool for LspReferences {
fn name(&self) -> &'static str {
"lsp_references"
}
fn description(&self) -> &'static str {
"Find all references to a symbol at a position"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier"
},
"path": {
"type": "string",
"description": "File path"
},
"line": {
"type": "integer",
"description": "Line number (0-based)"
},
"character": {
"type": "integer",
"description": "Character offset (0-based)"
}
},
"required": ["language", "path", "line", "character"]
})
}
#[instrument(skip(self, ctx, args))]
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let path = crate::tools::arg_str(args, "path")?;
let line = args.get("line").and_then(|v| v.as_i64()).unwrap_or(0);
let character = args.get("character").and_then(|v| v.as_i64()).unwrap_or(0);
info!(language, path, line, character, "LSP references requested");
let manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(client) = manager.get_client(&language) {
let result = client.send_request(
"textDocument/references",
&json!({
"textDocument": { "uri": format!("file://{}", path) },
"position": { "line": line, "character": character }
}),
)?;
Ok(serde_json::to_string_pretty(&result)?)
} else {
anyhow::bail!("no LSP client connected for '{language}'")
}
}
}
-2
View File
@@ -18,7 +18,6 @@
//! ├── executor.rs — InfrastructureToolExecutor
//! ├── fs/ — read, write, edit, delete
//! ├── git/ — git_operator, git_worktree, git_cred
//! ├── lsp/ — connect, disconnect, diagnostics, completion, etc.
//! ├── memory/ — remember, forget, recall
//! ├── utility/ — cd, dir_list, pong, todowrite, todofinish, etc.
//! ├── shell.rs — Bash tool
@@ -41,7 +40,6 @@ pub mod executor;
pub mod fs;
pub mod git;
pub mod graduated;
pub mod lsp;
pub mod memory;
pub mod parallel_delegate;
pub mod plan;
@@ -34,13 +34,6 @@ pub fn all_tools() -> Vec<Box<dyn super::Tool>> {
Box::new(super::utility::pong::Pong),
Box::new(super::utility::todowrite::Todowrite),
Box::new(super::utility::todofinish::Todofinish),
Box::new(super::lsp::LspConnect),
Box::new(super::lsp::LspDiagnostics),
Box::new(super::lsp::LspHover),
Box::new(super::lsp::LspCompletion),
Box::new(super::lsp::LspDefinition),
Box::new(super::lsp::LspReferences),
Box::new(super::lsp::LspDisconnect),
Box::new(super::web_search::WebSearch),
Box::new(super::semantic_search::SemanticSearch),
Box::new(super::semantic_search::RebuildIndex),