Skip to content

feat(execution): plan run configurations of a remote workspace on the host (Refs 1lck/Lithe-IDEA#2231) - #161

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/2231-remote-run-configs
Nov 22, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/2231-remote-run-configs

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

关联 Issue

1lck/Lithe-IDEA#2231(远程开发完整设计)R1 远程运行:远程工作区里的运行配置要在主机上解析、检查和启动。本 PR 是 Core 部分:让 runConfig.* 走工作区主机,并让启动计划直接给出主机路径。桌面端在主机上启动进程、运行标签页标记和输出路径映射另开 PR。

类型

  • feat:远程工作区的运行配置在主机上读取、校验和规划;不新增命令、错误码或宿主方法

改动说明

路由(crates/core/src/runtime/dispatcher.rs)

  • has_remote_workspace_adapter 加上 runConfig.。带 remoteWorkspace 的 runConfig.* 请求和 workspace.*、git.*、build.* 一样,在工作区主机的文件上执行。以前这些请求读的是本机占位目录,结果总是“没有配置”或“文件不存在”。

运行配置读主机文件(crates/execution/src/configuration*.rs、generated_layer.rs)

  • 配置文档、插件声明目录、脚本、程序、解释器和工作目录的检查从 std::fs 改为 lithe_workspace::fs。本地工作区的行为不变,远程工作区会转到主机去读。
  • 主机连不上时请求直接失败(is_transport_failure 转成 CoreError),不会当成“文件不存在”或“项目根目录不存在”。否则断线时编辑器会把已有的脚本标成缺失。
  • 测试里用来建本机文件的 fixture 仍用 std::fs,并加了注释说明。

进程按主机平台规划(configuration.rs 的 run_platform(),用在 form.rs、resolve.rs、validation.rs、launch.rs)

  • 远程主机只会是 Linux 或 macOS,所以远程工作区按 Platform::Unix 判断可用的进程类型、解释器和内联脚本后缀。Windows 客户端打开远程工作区时,不会规划出 batch 或 PowerShell 运行。
  • 本地工作区仍按 Platform::HOST。validation.rs 里配置路径格式的检查不受影响,仍是 Core 自己的规则。

启动计划给主机路径(launch.rs)

  • runConfig.createLaunchPlan 在远程工作区里把 executable.path、arguments 里的每一项和 inlineScript.path 映射回主机路径(lithe_workspace::remote_path,不在占位目录下的值不变)。客户端拿到计划后可以直接在主机上启动,不用自己翻译路径。
  • inlineScriptBase 由客户端给一个主机上的临时目录(桌面端用 fs.tempDirectory),内容由客户端写到主机,进程结束后再删掉。

为什么改到 execution crate

远程改动本来只放在 remote 和 workspace 两个 crate。execution 这里是必要的接线,和 build crate 走 lithe_workspace::fs 的做法一样:只换了文件访问入口、平台来源和计划里路径的方向,没有加任何远程专属逻辑。Windows 客户端上远端路径按本机规则处理的问题单独记在 1lck/Lithe-IDEA#2264,本 PR 不处理。

契约文档

  • contracts/rust-core-api.md:runConfig.createLaunchPlan 一节后面加一段,说明远程工作区里 runConfig.* 读主机文件、按主机平台规划、计划给主机路径、inlineScriptBase 必须是主机临时目录、主机连不上时请求失败。

验证

  • cargo fmt --all -- --check
  • cargo clippy -p lithe-execution -p lithe-core --all-targets --all-features -- -D warnings:无警告
  • cargo test -p lithe-execution:34 个通过
  • cargo test -p lithe-core:全部通过;新增 remote_run_configurations_resolve_and_plan_against_the_host,经过分发器在主机目录上验证:
    • 解析列出配置,可运行的条目没有 availability;
    • 脚本配置的计划是 /bin/bash,参数是 -e 和主机脚本路径,工作目录是 web;
    • 内联脚本落在客户端给的主机路径,扩展名是 .sh;
    • 主机上不存在的脚本返回 “Script file was not found”;
    • 编辑表单把工作目录改成不存在的文件夹时返回 workingDirectory: notFound,改成存在的文件夹后保存成功;
    • 本机占位目录全程是空的。
  • node shared/plugins/scripts/verify-docs.mjs:通过

… host (Refs 1lck/Lithe-IDEA#2231)

- runConfig.* is routed to the workspace host like workspace.*, git.* and
  build.*: configuration documents, scripts, interpreters and working
  directories are read and checked through lithe_workspace::fs.
- A host that cannot be reached fails the request instead of reporting a
  file or folder as missing.
- Process kinds, interpreters and inline script suffixes follow the host
  (Linux or macOS) through run_platform(), so a Windows client never plans
  a batch or PowerShell run on a remote host.
- runConfig.createLaunchPlan returns host paths for executable.path,
  arguments and inlineScript.path, so the client starts the process on the
  host without translating the plan.
- Test fixtures that build local files keep std::fs.
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