feat: LSP 集成(连接外部语言服务器,真实诊断/智能感知喂给模型)
- 新增 lsp_client.py:LspClient(subprocess stdio,Content-Length 分帧 JSON-RPC, reader 线程,initialize/initialized/didOpen/didChange/hover/definition/references/ completion + publishDiagnostics 通知捕获)+ LspManager(按扩展名→语言→server 路由、 connect_all 读 lspServers、get_context 返回已分析文件诊断、cleanup 幂等) - unified_tool_manager.py:initialize 末尾加载 LSP server,注册 5 个 lsp__* 工具 (diagnostics/hover/definition/references/completion,带真实 inputSchema、protocol='lsp'、 instance 存 manager 供 shutdown 清理) - cli_core.py:_build_system_prompt 末尾注入 LSP 诊断上下文(模型持续看到真实诊断) - config.json:顶层加 lspServers 段(python/rust 示例,含 _说明;该文件被 gitignore 不入库) - 新增 tests/test_lsp_client.py(9 项:fake server 全链路+路由+桥接+fc_tools 保真+缺失/失败优雅降级) - 修 LSP 线缆坑:didOpen/didChange 是通知(无响应),初版误当请求等响应导致超时 Co-Authored-By: WorkBuddy <workbuddy@tencent.com>
This commit is contained in:
1 parent
d2ad1000b6
commit
9dd418ec89
4 files changed
+1061
No files matched your search
@@ -268,6 +268,16 @@ multi 操作支持一次修改多处:
|
||||
if getattr(self, 'plan_mode', False):
|
||||
prompt += PLAN_MODE_SYSTEM_APPEND
|
||||
|
||||
# ── LSP 诊断自动注入:让模型持续看到真实语言诊断 ──
|
||||
liugin_manager = getattr(self, 'liugin_manager', None)
|
||||
if liugin_manager and hasattr(liugin_manager, 'get_lsp_context'):
|
||||
try:
|
||||
lsp_ctx = liugin_manager.get_lsp_context()
|
||||
if lsp_ctx:
|
||||
prompt += "\n\n# 当前代码诊断(来自 LSP 语言服务器)\n" + lsp_ctx
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return prompt
|
||||
|
||||
# ── JSON 解析 ──
|
||||
|
||||
Reference in new issue
Block a user