Skip to content

feat(remote): 自动发现容器环境并生成 Dev Container 基础配置 - #202

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/devcontainer-runtime-discovery
Nov 26, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/devcontainer-runtime-discovery

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue

改动说明

现有 Dev Container 入口需要用户先准备 devcontainer.json,也不能明确选择本机不同 Docker context 或 Windows WSL 中的引擎。本 PR 在 Core 提供真实环境发现、基础配置生成及完整的目标传递,供桌面端以表单引导创建;标准 JSON 仍是 Agent 和官方 Dev Container CLI 的共同输入。

  • 新增 remote.containerRuntimes:从 Docker CLI 读取 context 名称、描述和本地端点,实际探测 daemon 的就绪状态,保留 OrbStack、Docker Desktop、Linux Docker 的上游名称;沿用 Podman 支持。Windows 同时探测用户 WSL 发行版内的引擎,不修改全局 context,也不自动启动 daemon。
  • 环境目标统一为 { engine, context?, wsl? }。先校验再执行,显式 context 仅作用于子进程,并清除会覆盖所选 context 的继承 Docker 连接变量;WSL 使用独立参数传递。只接纳 unix:// / npipe:// 端点,避免把本机目录交给远程 daemon 挂载。
  • 发现最多 24 个目标、8 个用户发行版;单次 context 列举 5 秒、daemon 探测 3 秒、发现预算 60 秒,WSL 列举另有既有的 15 秒上限。超时和部分失败返回已发现结果及脱敏诊断,取消复用已有进程树清理。
  • 新增无 I/O 的 remote.devcontainerPrepare:校验名称、镜像或 Dockerfile、构建目录、用户、容器工作区、端口及创建后命令,生成标准 .devcontainer/devcontainer.json。镜像和 Dockerfile 二选一,构建路径相对工作区解释;端口去重且最多 64 个,生成仅监听回环地址的 appPort。
  • remote.devcontainerConfigs / remote.devcontainerUp 接受所选目标。WSL 文件夹通过 wslpath 解析,不假设 /mnt/c;配置查询返回 nativeFolder,供桌面端的确认写入和信任流程使用。WSL 只读列举使用 NUL 分隔和文件数上限。
  • remote.listContainers 可指定目标,与 sessionId 互斥,并校验 engine 一致性。构建、inspect、连接和重试保持同一 context / WSL 发行版;容器身份、exec 命令和信任键包含 Docker context,避免不同环境的同名容器复用信任。
  • 补齐应用边界文档、C ABI 文档和唯一共享 fixture rust/fixtures/remote/devcontainer-configuration-v1.json,桌面端直接消费这份 fixture。

Dev Container 的 features、生命周期、Compose 和镜像语义继续交给官方 CLI;Lithe 不重写该子系统,不额外添加挂载或权限,也不引入新的打包运行时。

应用 ABI 与兼容性

原计划编号 方法 用途
— remote.containerRuntimes 新增:发现可用容器环境与就绪状态
— remote.devcontainerPrepare 新增:校验基础表单并生成标准配置,不写文件
— remote.devcontainerConfigs 扩展:在选定环境列举配置,返回原生文件夹路径
— remote.devcontainerUp 扩展:在选定环境调用官方 CLI,返回相同目标
— remote.listContainers 扩展:按选定环境列举容器
— remote.connect 扩展:容器连接保留 Docker context,纳入身份和信任

以上为宿主应用 C ABI 命令,不是插件 RPC 方法。没有修改 shared/plugins/contract/、插件能力版本、插件进程协议或四语 SDK,因此不提升插件 API / schema / 协议版本;原有请求省略目标时保持原行为。应用契约与 fixture 仅存于本仓库,桌面端固定 Core 主线 commit 38c60be716207fa99cd2f8827f81e7e7c75c4eb1(与本分支提交内容相同)。

验证

本地仅验证改动范围,未运行整个 Rust workspace。执行主机为 macOS;Windows target clippy 只证明编译检查通过,不代表 Windows 原生运行验收。

命令或操作 结果
cargo test --manifest-path rust/Cargo.toml -p lithe-workspace --lib container --no-default-features 22 项通过
cargo test --manifest-path rust/Cargo.toml -p lithe-remote --lib client::container 6 项通过
cargo test --manifest-path rust/Cargo.toml -p lithe-remote --lib client::trust 10 项通过
cargo clippy --manifest-path rust/Cargo.toml -p lithe-core -p lithe-workspace -p lithe-remote --all-targets --all-features -- -D warnings 通过
LIBSQLITE3_SYS_USE_PKG_CONFIG=1 ZSTD_SYS_USE_PKG_CONFIG=1 PKG_CONFIG_ALLOW_CROSS=1 cargo clippy --manifest-path rust/Cargo.toml -p lithe-core -p lithe-workspace -p lithe-remote --all-targets --all-features --target x86_64-pc-windows-msvc -- -D warnings 通过,未链接或运行 Windows 程序
cargo fmt --manifest-path rust/Cargo.toml --all -- --check 通过
CARGO_TARGET_DIR="$PWD/rust/target" scripts/rust-core/verify-rust-core-comments.sh remote workspace core 通过
node scripts/rust-core/verify-platform-tests.mjs 53 个 crate 放置检查通过
桌面端读取当前 Core fixture 的桥接测试、受影响容器工作流测试及竞态检查 通过,命令和截图见配套桌面端 PR
真实 OrbStack + 官方 Dev Container CLI 0.91.0 + Alpine 3.21 生成 / 写入 / 回读配置 → up → 创建后命令经真实挂载写标记 → 指定 context 连接 → 校验并上传远端服务 → 读取标记通过(2.04 秒);会话和本次唯一工作区的容器已清理
git diff --check 通过

日志使用既有统一日志路径;上游诊断只供显示,不作为自由文本存入日志。新增代码和测试不依赖任何具体插件。既有具体插件 fixture / 文档归属债务复用 桌面端 #2435 和 Core #195,不在此 PR 顺手修改。

尚未完成的检查与范围

提交前确认

  • 目标 main;提交 d1b86b55f344af572fd472edaf60d91240cf1149 已推送,工作区干净。
  • 创建时指定 Draft;本 PR 现已合入。上述原生验收与门禁缺口继续在桌面端 #2438 明确保留。
  • 未提交编译产物、日志、凭据或个人路径;未增加 AI 署名。
  • 本次集成测试的会话、临时容器和子进程已清理。

…nfigurations

Discover local Docker contexts, Podman and Windows WSL runtimes with bounded probes. Generate standard devcontainer configuration from basic form inputs and preserve the selected context and distribution through build, connection and trust.
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 26, 2026 07:18
@xiaoyumuxi
xiaoyumuxi merged commit 38c60be into main Nov 26, 2026
7 of 8 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