Skip to content

feat(desktop, agent-core): 接入 TypeScript LSP 诊断与 Agents 设置页#69

Merged
N123999 merged 13 commits into
mainfrom
feat/lsp-bootstrap
Jun 4, 2026
Merged

feat(desktop, agent-core): 接入 TypeScript LSP 诊断与 Agents 设置页#69
N123999 merged 13 commits into
mainfrom
feat/lsp-bootstrap

Conversation

@N123999

@N123999 N123999 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 在 agent-core 新增 LSP 模块:TLS 连接、诊断缓存、get_diagnostics 宿主工具,以及写文件后同步诊断并附摘要。
  • Desktop 运行时接入 LSP:tool executor 暴露诊断工具,写后 append 诊断;工具卡展示 LSP 错误/警告徽章与 hover 详情。
  • 设置侧栏新增「智能体 / Agents」选项卡:LSP 总开关、provider 发现列表、未安装时经确认一键 npm install -g;偏好持久化至 config.jsonagents.lsp.enabled
  • 关闭 LSP 时禁用 get_diagnostics 与写后诊断;配置变更后 dispose 缓存并重建 executor。
  • 补充 agent-core provider/probe 单测、Desktop snapshot 与 orchestrator 相关单测。

Test plan

  • npm run build:agent-corenpm run build:desktop
  • node --test packages/agent-core/dist/lsp/providers.test.js packages/agent-core/dist/lsp/service-probe.test.js
  • node --test apps/desktop/test/host/lsp-snapshot.test.mjs
  • 手动:PATH 有 TLS 时 Agents 页显示 Ready,Agent 可用 get_diagnostics 与写后徽章
  • 手动:关闭 LSP 开关后无诊断工具与写后检查
  • 手动:PATH 无 TLS 时显示安装按钮,安装成功后列表变 Ready

N123999 added 12 commits June 4, 2026 20:29
引入 lsp 目录、PATH 解析 typescript-language-server、诊断文本格式化及单测;添加 vscode-jsonrpc 与 vscode-languageserver-protocol 依赖。
新增 LspConnection、文档同步与 LspService;支持 publishDiagnostics 缓存、防抖 didChange 及按路径拉取诊断。
HostToolExecutorProxy 与 DesktopToolExecutor 集成 LspService;PATH 无 typescript-language-server 时不暴露工具。
fileChangeObserver 触发文档同步;写类工具成功后追加 [lsp] 诊断摘要块。
补充 Ask 模式工具可见性、tool-request/write-append 单测与 lsp-typescript-smoke;eval:scenario:validate 通过。
host-bridge 进程退出前 dispose LSP;Desktop 切换工作区时释放非当前 workspace 的 LspService 缓存。
DesktopToolRequest 联合类型不含 LSP 工具;经 JsonValue 守卫后再读取 path,消除 build:electron 报错。
流式回合在 tool preview 后以 before-next-tool 固化思考;defer 仅在整轮尚无工具行时生效。timeline 新 segment 前完成上一段,UI 不再渲染空 Thought。Windows 上对 .cmd/.bat 使用 shell spawn,并补充 connection 单测。
正文已出现后不再 defer 到 aux;首个 tool preview 前以 before-next-tool 固化。stripSegmentAux 仅匹配同文 aux;before-next-tool 在无工具时落入 before-tools 段。UI 在后续仍有工具时保持已固化 Thought 可见。
TLS 5.x 须在 initialize 声明 publishDiagnostics,否则 diagnosticsSupport 为 false 且不会推送诊断。Windows 上统一 TLS 返回的 file URI(盘符大小写、d%3A 编码),避免诊断缓存键与 waiter 不一致。get_diagnostics 调用前清除旧缓存;新增集成测试覆盖类型错误上报与二次调用。

已撤销调试阶段基于错误根因的改动:diagnosticsQuietMs 静默等待、writeAppend 超时加长、sync 路径上的 invalidate 及 Cursor ingest 埋点。
写工具完成后等待诊断稳定并透传 hostUi 至 Desktop snapshot;工具卡 headline 旁显示 error/warning 计数与 Hover 详情,色阶与文件名一致。
在 Desktop 设置中新增「智能体」选项卡,含 LSP 总开关、provider 发现列表与
npm 全局安装;偏好写入 config.json agents.lsp,关闭时禁用诊断工具与写后检查。
@N123999

N123999 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.

const diagnostics = await lsp.getDiagnosticsForPath(
resolvedPath,
DEFAULT_LSP_TIMING.diagnosticsWaitMs,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write append uses wrong wait

Medium Severity

appendLspDiagnosticsAfterWriteIfNeeded waits on diagnosticsWaitMs (4s) instead of the dedicated writeAppendDiagnosticsWaitMs (1.5s), so every successful TS/JS write blocks tool completion on the longer agent-facing timeout.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.

Comment thread apps/desktop/src/host/lsp-commands.ts Outdated
ctx.invalidateToolExecutors();
await ctx.refreshLspSnapshot();
ctx.activeBundle().deferredRuntimeRefreshWhileBusy = false;
await ctx.refreshRuntime();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install forces runtime refresh

Medium Severity

installLspProviderCommand clears deferredRuntimeRefreshWhileBusy and always calls refreshRuntime, even when the agent runtime is already busy, which can rebuild the active session runtime mid-turn instead of deferring like other config changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.

write-append 改读 writeAppendDiagnosticsWaitMs(默认 4s,实测 1.5s 常无诊断);
installLspProvider 在 runtime busy 时设 deferredRuntimeRefreshWhileBusy,与 config 变更一致。
@N123999 N123999 merged commit a93ff64 into main Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant