Skip to content

feat(debug): targetBindings.cwd 可以绑到 target.directory - #56

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/debug-cwd-target-directory
Nov 15, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/debug-cwd-target-directory

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

背景

#55 合入时用的是 671cdc6,后来推到同一分支的 268d9a2(targetBindings.cwd ← target.directory)没有进 main。本 PR 把它 cherry-pick 到最新 main 重新提交。

调试引擎 perform_launch(rust/crates/debug/src/engine.rs)在 launch 参数缺 cwd 时把 cwd 填成工作区根目录。所以即使有了 #55 的 dlvCwd 和 env.PWD,Delve 能在包目录编译,被调程序仍在工作区根目录运行,按包目录写的相对路径(例如 examples/greeting.txt)读不到。Go 插件 e2e 的多模块工作区用例就因此 panic。

改动

  • validate_configuration.rs:targetBindings.cwd 的允许值从只有 target.workingDirectory 扩到 target.workingDirectory 或 target.directory,其他值报 cwd can only be bound to target.workingDirectory or target.directory.。
  • plan.rs:cwd 和 adapterArguments 共用一段事实检查。缺工作目录时报 target.workingDirectory;路径是裸文件名、取不出目录时报 target.path。
  • start.rs:cwd 绑定改用 path_fact() 取值。
  • declaration.rs、rust/contracts/rust-core-api.md:文档注释与 Core API 说明。
  • plugin-manifest.schema.json:targetBindings.cwd 从 const 改为两个值的枚举。
  • contract/v1/README.md、guides/debug-adapter-plugin.md、reference/domains/debug-adapters.md(中英):写明 cwd ← target.directory,以及调试引擎在缺 cwd 时用工作区根目录。
  • fixtures/debug-adapters/debug-adapter-rejections.json:新增 cwd-from-target-path。
  • reference/protocol-changelog.md:2026-11-15 新增 feat(debug): targetBindings.cwd 可以绑到 target.directory #56 一行(API-30,debugAdapters 0 内的补充)。
  • 测试(rust/crates/core/src/tests/declarative_plugins.rs):
    • 新增 debug_start_arguments_bind_cwd_to_the_directory_of_the_target:cwd ← target.directory 取源文件所在目录,cwd ← target.workingDirectory 不变,裸文件名路径和缺工作目录分别被拒绝。
    • debug_start_arguments_fill_adapter_arguments_from_path_facts 同时绑 cwd ← target.directory。

关联

验证

  • cargo fmt --all -- --check
  • cargo clippy --locked -p lithe-debug -p lithe-core --all-targets --all-features -- -D warnings
  • cargo test --locked -p lithe-debug -p lithe-core -p lithe-plugin-model:lithe-core 810 个测试全部通过。
  • scripts/rust-core/verify-rust-core-comments.sh debug core
  • node shared/plugins/scripts/verify-docs.mjs
  • 268d9a2 上还跑过 node scripts/rust-core/verify-platform-tests.mjs 和 Windows 目标 clippy,都通过。

调试引擎在 launch 参数缺 cwd 时会把 cwd 填成工作区根目录,
多项目工作区里 Delve 启动的程序因此在根目录运行,按包目录读的相对路径文件找不到。
cwd 绑定新增 target.directory:被调程序在源文件所在目录运行。
同步 schema、契约 README、指南、参考页与协议更新记录(#56 新行),补测试和拒绝 fixture。

#55 合入时没有带上这个提交,从最新 main 重新提交。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 15, 2026 10:42
@xiaoyumuxi
xiaoyumuxi merged commit 9425469 into main Nov 15, 2026
7 of 10 checks passed
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