Repository navigation
feat(debug): tcpAnnounced 公告解析命令与 target.directory 程序绑定 - #47
Merged
Merged
Conversation
- 新增 debug.adapters.readAnnouncement:宿主把 tcpAnnounced 适配器的输出逐行交给 Core, 第一行含 prefix 的输出是公告,前缀之后是 port(连 127.0.0.1)或带回环主机的 host:port (IPv6 加方括号);返回 none、announced 或 invalid(malformed、notLoopback), 非回环地址一律拒绝。用例在 rust/fixtures/debug/adapter-announcements-v1.json。 - targetBindings.program 新增来源 target.directory:target.path 所在的目录,供 Delve 这类按包构建再调试的适配器使用;路径没有所在目录时以 debug.target.invalid (字段 target.path)拒绝。schema 枚举、契约 README、参考页、指南同步更新。 - tcpAnnounced 端点校验抽成 DebugEndpoint::is_announced,清单校验和新命令共用。 - rust-core-api.md 写明宿主怎样读公告,并去掉已删除的 macOS 宿主的传输说明; 模块说明去掉过时的 API level 4。
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 04:18
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Go 插件要接入 Delve 调试(
dlv dap)。Delve 有两个现有契约做不到的地方:dlv dap只监听 TCP,启动后在 stdout 打印DAP server listening at: 127.0.0.1:<端口>。契约早就有tcpAnnounced传输,但没有宿主实现,也没有规定“哪一行是公告、怎样读端点”。固定端口(tcpPort)会和用户机器上的其他进程冲突。program是包目录(它会go build整个包)。只传当前文件target.path会让多文件包编译失败。这两处都是通用逻辑,放进 Core,各平台宿主共用;Core 里没有任何 Go 或 Delve 的特判。
改动
新命令
debug.adapters.readAnnouncement(API-30)tcpAnnounced适配器的输出逐行交给 Core,入参是{ endpoint, stream, line };其中endpoint就是启动计划里的debugAdapter.endpoint。prefix:返回{ status: "none" },宿主继续读下一行。prefix的第一行就是公告,取前缀之后、去掉首尾空白的部分:value: "port":1–65535 的十进制端口,主机固定为127.0.0.1。value: "hostPort":host:port或[ipv6]:port,主机必须是回环地址(localhost、127.0.0.0/8、::1)。{ status: "announced", host, port }。否则返回{ status: "invalid", reason: "malformed" | "notLoopback" },例如0.0.0.0、::ffff:127.0.0.1或远程主机名。tcpAnnounced声明、流名未知、或带未知字段时,返回invalid_request。rust/fixtures/debug/adapter-announcements-v1.json。debug crate 的单测和 core 的 JSON 边界测试都读它。targetBindings.program: "target.directory"target.path所在的目录,用Path::parent,所以对各平台的原生路径都成立。target.path缺失,或者是不带目录的裸文件名时,以debug.target.invalid(字段target.path)拒绝。validate_configuration允许的来源corePlan拒绝用例debug_start_arguments_bind_program_to_the_directory_of_the_target顺手整理
tcpAnnounced的端点校验抽成DebugEndpoint::is_announced,清单校验和新命令共用一份。rust-core-api.md:plugin.launch.unsupportedTransport拒绝。adapters.rs的模块说明去掉过时的 “API level 4”。文档
target.directory;新增一行“launch.endpointfortcpAnnounced”,写明宿主怎样读公告、10 秒超时,其余输出进调试控制台。domains/debug-adapters.md中英两段、指南debug-adapter-plugin.md中英两段都已更新,指南补了dlv dap的tcpAnnounced示例。protocol-changelog.md:新增 2026-11-15 条目,记为debugAdapters0 内的补充,不需要新能力版本。宿主方法
本 PR 不新增、不修改
lithe/host/*宿主方法或通知。新增的只是桌面端调用的 Core 命令。验证
cargo test -p lithe-debug -p lithe-plugin-manifest -p lithe-core:全部通过,core 795 个、debug 106 个cargo clippy -p lithe-debug -p lithe-core --all-targets -- -D warnings:通过cargo fmt --all:已格式化scripts/rust-core/verify-rust-core-comments.sh:通过node shared/plugins/scripts/verify-docs.mjs:通过node --test shared/plugins/scripts/*.test.mjs:通过后续
tcpAnnounced托管,并把PINNED_CORE_REVISION升到本分支。program: "target.directory"、tcpAnnounced)和 Go 项目生成器。