Skip to content

[Feature] 宿主托管 tcpAnnounced 调试适配器:拉起进程、读取它输出的回环端口后连接(Go 的 Delve 需要) #1953

Closed

Description

@xiaoyumuxi

Problem to solve / 要解决的问题

插件契约早就有 tcpAnnounced 调试传输:适配器进程自己选一个本机端口监听,在输出里打印这个端口,编辑器读到后再连接。Viva 桌面端目前只接了 stdio 和 tcpLanguageServer 两种传输,声明 tcpAnnounced 的适配器在启动前就被拒绝(plugin.launch.unsupportedTransport)。

影响:只监听 TCP 的调试器没法接入。典型是 Go 的 Delve:dlv dap 不支持 stdio,启动后在 stdout 打印 DAP server listening at: 127.0.0.1:<端口>。Go 插件(io.github.lithe-idea.go-support)因此没有调试能力,用户只能在终端里手动跑 dlv。改用固定端口(tcpPort)又会和用户机器上的其他进程冲突。

Proposed solution / 建议方案

宿主托管 tcpAnnounced 适配器,规则放在 Rust Core,宿主不按插件或工具名加分支:

  1. Core 新增 debug.adapters.readAnnouncement:宿主把适配器声明的输出流逐行交给 Core,Core 按清单里的 launch.endpoint(stream、prefix、value: port | hostPort)判定这一行是不是公告;只接受回环地址,其他地址判为无效。(已在 feat(debug): tcpAnnounced 公告解析命令与 target.directory 程序绑定 Lithe-IDEA/Lithe-core-rust#47 合入。)
  2. 桌面端拉起适配器进程,逐行读取并询问 Core;公告行不进调试控制台,其余输出照常显示。读到端点后沿用 Core 驱动的 TCP 传输生命周期连接;端点发现期限沿用 Core 的默认 10 秒。
  3. 失败要有明确原因并停止进程:公告前进程退出、公告了非本机地址、超时没有公告。
  4. 用户停止调试时先把 DAP disconnect 送到网络栈,再停止适配器进程。
  5. Go 插件随后声明 Delve 适配器(dlv dap,tcpAnnounced),并通过 projectGenerators 在“新建项目”里加入 Go 项目。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Debug / 调试

Priority / 优先级

P1 / 尽快处理:使用体验大幅下降,但通常仍可继续使用

Alternatives considered / 已考虑的替代方案

  • tcpPort:宿主先选端口再传给进程。端口可能已被占用,而且 Delve 的端口是它自己选的,宿主无法预先知道。
  • 在宿主里按 Delve 的输出格式写死解析:违反“工具专属知识不进宿主”的规则,其他只监听 TCP 的适配器(例如 debugpy 的监听模式)还要再写一遍。
  • 通过 tcpLanguageServer 转接:Delve 不是语言服务器托管的调试服务,不适用。

Additional context / 补充信息

  • 契约:Lithe-IDEA/Lithe-core-rust 的 shared/plugins/contract/v1/ 中 debugAdapters.launch.transport: tcpAnnounced 与 launch.endpoint。
  • Core 用例:rust/fixtures/debug/adapter-announcements-v1.json(40 条)。
  • 同一 Core PR 还新增了 targetBindings.program: "target.directory",Delve 的 program 是包目录而不是单个文件。

Checklist / 提交前检查

  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    review: high

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions