Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f62230c
feat(toolchains): 接入插件工具链提供方
Mucheen Nov 19, 2026
6b5e9e8
Merge desktop main into toolchain provider branch
Mucheen Nov 19, 2026
8b80afb
test(toolchains): reuse the fixture executable image
Mucheen Nov 19, 2026
0da04e3
fix(toolchains): preserve fallback when provider discovery times out
Mucheen Nov 19, 2026
d0fae42
build(core): use the shared Python integration revision
Mucheen Nov 19, 2026
693f944
fix(toolchains): query the selected plugin version and form tools
Mucheen Nov 19, 2026
0229bd6
Merge desktop main and retain its Core revision
Mucheen Nov 19, 2026
39ccfbb
Merge branch 'main' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
a2c037c
Merge branch 'main' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
0dd2ca5
test(toolchains): compare provider upgrade paths in native form
Mucheen Nov 19, 2026
ca71cf5
fix(terminal): wait for shell hangup before closing the PTY
Mucheen Nov 19, 2026
7d2a5f4
Merge commit '3fe59a9d1' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
3b625f6
fix(workspace): display trust locations with native path separators
Mucheen Nov 19, 2026
4c9be5a
fix(terminal): retry a missed hangup at the Bash prompt
Mucheen Nov 19, 2026
5358e19
Merge branch 'main' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
46035f0
Merge branch 'main' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
c31de62
Merge branch 'main' into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
7aef0d9
Merge main into codex/2122-desktop-toolchain-providers
Mucheen Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Viva 桌面端现在把插件声明的工具链接进了设置和构建执行:Core 仍是唯一决定“哪个安装生效”的地方,Go 只做声明式扫描、文件事实读取、有界版本探测和原子保存。设置页的 Build 页按插件声明的工具显示当前生效值与来源;用户选择只改草稿,明确 Save 才写 `.lithe/toolchains/local.json`,Cancel 不写。Build 命令任务、Build 模型和 Provider 应用的 `toolchain` 候选都复用同一次解析,启动时使用 Core 返回的可执行文件、导出环境和 PATH。

这一批没有接入提供方后端查询(`toolchainProviders`),也没有因此声明该能力;Windows 原生保存与相关组件已在 Lithe-dev 验证,完整 GUI 流程仍未验收。
工具链提供方(`toolchainProviders`)在设置、运行或新建项目需要发现结果时,复用插件的共享后端。工作区与全局查询采用同一套文件事实校验和 Core 解析。原生窗口的完整流程仍待验收。

## 问题

Expand All @@ -22,11 +22,23 @@ Viva 桌面端现在把插件声明的工具链接进了设置和构建执行:
- Core 返回的可执行路径可用正斜杠,Windows 原生扫描和 pin 可能使用反斜杠或不同大小写。执行探测前按原生路径身份合并别名,并把本机路径交给进程适配器;不把同一程序的多个拼写当作多份探测事实。Windows 回归已先复现同一程序被探测三次及 pin 解析因重复证据遭拒绝,修复保留 Core 的严格证据校验。
- 扫描不到安装、版本不满足或工具被两个插件争用时,界面显示 Core 的稳定原因,不伪造默认安装。争用工具不注册,宿主不按插件 ID 替用户选择。

### 按需发现提供方安装

共享插件后端在首次查询时启动,查询与函数调用都用 Core 的会话及取消入口。一个工作区查询带打开时的上下文 ID 和代次。工作区关闭或重开后,旧上下文不能继续发布结果。用户固定的运行目标可以独立解析。

查询使用注册表清单中的插件版本,缓存键也含同一份清单。升级后的首次查询先确认新版本仍是当前启用版本,再结束旧后端并启动新后端。旧版迟到查询不能替换现用会话。新建项目只对表单需要的工具运行发现与探测,未选工具的提供方故障不会阻断表单。

每个工具的同一轮回包共用一个代次。桌面收集声明布局、要求来源和观察路径的原生事实,Core 负责校验身份、路径范围、安装与版本要求。为设置和运行缓存的是有界原始回包,每次使用仍按当前文件事实校验。缺失的输入由最近的现存父目录负责观察,文件变化会使整轮重新查询,已有进程保持自己的启动参数。关闭项目、停用或重新加载插件时,释放观察器并结束相应会话。

例如用户创建原本缺失的版本要求文件时,下次解析应重新调用提供方并使用完整的新回包。仅重新探测上轮已发现的程序无法反映新文件。沿用原生目录事件避免空闲轮询,且让替换写不会留下指向旧文件的监听。

整轮提供方查询有独立的期限。到期时保留已完成的回包,并请 Core 为剩余提供方生成超时回包,以便同一次解析仍能使用本机候选;用户取消或工作区关闭则终止解析。用 `TestToolchainProviderRoundPreservesAnswersAtItsDeadline` 检查已收到的回包和未发出的查询。

### 读取真实来源,明确保存

工具链快照另保存从已打开目录句柄立即读取的工作区身份。保存前同时核对读取时来源和活动项目的身份,不能只比较两个当前路径;原路径被改名并重建时,即使本地文档仍缺失或字节相同,也要拒绝。Core 编辑期间和最终发布前再次核对,防止校验期间替换根目录。已有确认后切换到另一个项目仍只写捕获的原目录并回读原目录;这与替换原目录是不同情况。

- 设置页 Build 页显示每个工具的有效安装、版本、层级和 pin 来源;登录 Shell 的 home 候选单列显示,并说明提供方安装尚未查询。
- 设置页 Build 页显示每个工具的有效安装、版本、层级和 pin 来源;登录 Shell 的 home 候选单列显示,提供方安装进入同一安装列表。
- 选择只修改窗口草稿;Save 才把整批变化交给 Core。来源文件的路径、字节预算、缺失时默认值、完整 schema 与重复 JSON 键检查都由 Core 给出;没有已安装工具也必须校验 dormant pin。Go 使用已有 `configfile` 适配器按预算读取 UTF-8,不先解析或补默认文档。原生选项未指定平台时采用当前宿主,不能把空平台字符串交给 Core。
- `toolchains.editPinSources` 同时返回本地文档与忽略文件的编辑计划。没有语义变化时保留原字节和缺失状态;例如对不存在的 pin 执行重置,不能创建 `.lithe`。旧 `editPins` 的选择与合并规则继续复用,不重写内核。
- 忽略规则使用 Core 固定版本 `ignore` 的完整匹配器。只调用 `GitignoreBuilder` 的内存行解析和匹配,不启用目录遍历、全局规则发现或线程池;许可证为 MIT/Unlicense,资源开销仅发生在明确保存时。已经生效的通配规则保持原样;后续否定规则取消忽略时,在末尾追加明确规则,保留评论、已有行与换行风格。不在 Go 用“是否包含一行”代替 Git 规则。输入与输出都检查字节和行数预算,避免发布下次无法读取的来源。
Expand Down Expand Up @@ -71,13 +83,13 @@ Windows 的工具发现和构建模型测试要保留两条真实本机边界:

- **在 Go 里扫描目录并维护 Maven/JDK 优先规则。** 能最快让界面有内容,但会重造 Core 已校验的四层选择和工具知识,第二个工具就要再改宿主,因此不采用。
- **只做设置页,不接 Build。** 页面可展示但用户仍无法使用所选路径;无法验证“探测结果与启动目标一致”,因此先接执行。
- **声明 `toolchainProviders` 后再补查询。** 会让市场允许带后端的工具链插件安装,但本客户端无法发 `toolchains/query`,首次使用才失败;所以本批不声明该能力。
- **用文件监听做实时刷新。** 会新增常驻监听和失效规则;本批在打开页面和显式 Reload 时读取,避免未验收的 watcher 生命周期。
- **单独为每次查询启动一份提供方进程。** 同一插件同时提供语言配置和工具链时,进程启动与初始化会重复。共享后端可在同一连接中区分操作,并由同一个插件生命周期释放。
- **每次都重新向提供方请求。** 工具选择会在设置和多个运行入口反复执行。采用短期有界缓存和原生观察,输入变动时重查,空闲时无需轮询。
- **在宿主 CI 下载真实插件和工具做 Windows 回归。** 会引入具体插件依赖、网络与安装布局,不能稳定控制失败形态;宿主只测试合成工具的通用流程,真实工具在插件仓库验收。

## 后果

收益是设置显示与 Build/Run 启动共享同一份 Core 结果,新增工具只需插件声明,不需改宿主工具表。代价是提供方查询、目录树多来源合并、手动“添加安装”和输入文件监听仍未实现;保存的 JSON 编辑规则由 Core 持有,平台仅负责有冲突检查的原生写入。
收益是设置显示与 Build/Run 启动共享同一份 Core 结果,新增工具只需插件声明,不需改宿主工具表。提供方查询需要临时后端和有限的观察器注册。达到观察范围上限后只保留当次结果;保存的 JSON 编辑规则由 Core 持有,平台负责有冲突检查的原生写入。

Windows 已运行真实 Core 的工具链与工作台组件测试,并以受保护的用户专属访问控制列表验证原子保存保留原权限。原生程序识别与权限发布的取舍见 `../bug-fix/2026-11-09-viva-windows-native-file-validation.md`;路径大小写的完整工作流、GUI 和发行包验收仍待补。

Expand All @@ -104,6 +116,7 @@ Windows 运行 `./.agents/skills/write-stable-tests/scripts/test-stability-windo

- `desktop/internal/core/toolchain.go`
- `desktop/internal/toolchain/`
- `desktop/internal/pluginservice/toolchain_provider.go`
- `desktop/internal/settingswindow/toolchains_view.go`
- `desktop/internal/workbench/toolchains.go`、`settings_toolchains.go`、`build.go`
- `desktop/internal/toolchain/path_windows_test.go`、`desktop/internal/workbench/build_command_windows_test.go`
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/desktop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,28 @@ jobs:
if-no-files-found: error
retention-days: 14

- name: Capture toolchain provider settings
id: toolchain-provider-visual
if: ${{ !cancelled() && steps.rust.outcome == 'success' }}
timeout-minutes: 5
env:
LITHE_VISUAL_OUTPUT_DIR: ${{ github.workspace }}/.artifacts/toolchain-provider-visual
run: |
for language in en zh-Hans; do
LITHE_VISUAL_LANGUAGE="$language" LITHE_VISUAL_OUTPUT_DIR="$LITHE_VISUAL_OUTPUT_DIR/$language" \
./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/settingswindow \
-run '^TestVisualSettings$/^m51-toolchain-provider-installation' -count=1 -timeout=120s
done

- name: Upload toolchain provider settings screenshots
if: ${{ !cancelled() && steps.toolchain-provider-visual.outcome != 'skipped' }}
uses: actions/upload-artifact@v7
with:
name: toolchain-provider-visual-${{ runner.os }}-${{ runner.arch }}
path: .artifacts/toolchain-provider-visual/**/*.png
if-no-files-found: error
retention-days: 14

- name: Upload native verification reports
if: always()
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -281,6 +303,7 @@ jobs:
run: ./scripts/desktop/check.sh

- name: Capture native settings and diagnostic screenshots
id: native-settings-visual
env:
LITHE_VISUAL_OUTPUT_DIR: ${{ github.workspace }}/.artifacts/native-settings-visual
run: |
Expand All @@ -302,7 +325,7 @@ jobs:
done

- name: Upload native settings visual evidence
if: always()
if: ${{ !cancelled() && steps.native-settings-visual.outcome != 'skipped' }}
uses: actions/upload-artifact@v7
with:
name: native-settings-visual-${{ runner.os }}-${{ runner.arch }}
Expand Down Expand Up @@ -381,6 +404,7 @@ jobs:
run: ./scripts/desktop/check.sh

- name: Capture native settings and diagnostic screenshots
id: native-settings-visual
env:
LITHE_VISUAL_OUTPUT_DIR: ${{ github.workspace }}/.artifacts/native-settings-visual
run: |
Expand All @@ -402,7 +426,7 @@ jobs:
done

- name: Upload native settings visual evidence
if: always()
if: ${{ !cancelled() && steps.native-settings-visual.outcome != 'skipped' }}
uses: actions/upload-artifact@v7
with:
name: native-settings-visual-${{ runner.os }}-${{ runner.arch }}
Expand Down
19 changes: 10 additions & 9 deletions desktop/internal/core/plugin_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
// PluginBackendStart is the host-resolved process and workspace. The host must
// only supply programs and grants from an approved, verified plugin package.
type PluginBackendStart struct {
ProviderID string `json:"providerId"`
PluginID string `json:"pluginId"`
Role string `json:"role,omitempty"`
ExecutablePath string `json:"executablePath"`
Arguments []string `json:"arguments,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
RootURI any `json:"rootUri"`
WorkingDirectory string `json:"workingDirectory"`
HostServices []string `json:"hostServices,omitempty"`
ProviderID string `json:"providerId"`
PluginID string `json:"pluginId"`
Role string `json:"role,omitempty"`
ExecutablePath string `json:"executablePath"`
Arguments []string `json:"arguments,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
RootURI any `json:"rootUri"`
WorkingDirectory string `json:"workingDirectory"`
HostServices []string `json:"hostServices,omitempty"`
ToolchainProviders []string `json:"toolchainProviders,omitempty"`
// FunctionRelayEnabled isolates preparation sessions from both incoming and
// outgoing cross-plugin calls. Omitted preserves ordinary backend behavior.
FunctionRelayEnabled *bool `json:"functionRelayEnabled,omitempty"`
Expand Down
101 changes: 101 additions & 0 deletions desktop/internal/core/toolchain_provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package core

import (
"context"
"encoding/json"
)

// ToolchainQueryContext is the captured identity of the open workspace.
type ToolchainQueryContext struct {
ID string `json:"contextID"`
Generation uint64 `json:"generation"`
}

// ToolchainQueryWorkspace identifies the directory for one provider query.
type ToolchainQueryWorkspace struct {
RootID string `json:"rootID"`
Root string `json:"root"`
Directory string `json:"directory"`
}

// ToolchainQueryParams remain the same from submission to reply validation.
type ToolchainQueryParams struct {
OperationID string `json:"operationID"`
Generation uint64 `json:"generation"`
ProviderID string `json:"providerID"`
Authority map[string]string `json:"authority"`
Context *ToolchainQueryContext `json:"context"`
Workspace *ToolchainQueryWorkspace `json:"workspace"`
Tools []string `json:"tools"`
}

// ToolchainProviderReply preserves the real wire identity and raw response.
type ToolchainProviderReply struct {
ID json.RawMessage `json:"id"`
Response json.RawMessage `json:"response"`
}

// ToolchainProviderSnapshot contains the reply facts validated by Core.
type ToolchainProviderSnapshot struct {
Installations []ToolchainProviderInstallation `json:"installations"`
Watch []string `json:"watch"`
}

const (
ToolchainProviderUnavailable = "plugin.toolchain.providerUnavailable"
ToolchainProviderTimeout = "plugin.toolchain.timeout"
)

// RequestPluginToolchain queues a query on the plugin's initialized backend.
func (c *Client) RequestPluginToolchain(ctx context.Context, sessionID string, params ToolchainQueryParams, timeoutMS int) error {
return c.Execute(ctx, "lsp.toolchainRequest", struct {
SessionID string `json:"sessionId"`
OperationID string `json:"operationId"`
Params ToolchainQueryParams `json:"params"`
TimeoutMS int `json:"timeoutMilliseconds"`
}{sessionID, params.OperationID, params, timeoutMS}, nil)
}

// ToolchainFailureReply asks Core to encode a missing transport reply.
func (c *Client) ToolchainFailureReply(ctx context.Context, params ToolchainQueryParams, code string) (ToolchainProviderReply, error) {
const command = "toolchains.failureReply"
var result struct {
Status string `json:"status"`
Reply *ToolchainProviderReply `json:"reply"`
Error *MarketplaceRejection `json:"error"`
}
request := struct {
Params ToolchainQueryParams `json:"params"`
Code string `json:"code"`
}{params, code}
if err := c.Execute(ctx, command, request, &result); err != nil {
return ToolchainProviderReply{}, err
}
if result.Error != nil {
return ToolchainProviderReply{}, result.Error
}
if result.Status != "ok" || result.Reply == nil {
return ToolchainProviderReply{}, newParseError(command, "toolchains.failureReply returned no reply", "")
}
return *result.Reply, nil
}

// DecodeToolchainReply verifies the raw reply against authority-local facts.
func (c *Client) DecodeToolchainReply(ctx context.Context, query ToolchainQuery) (ToolchainProviderSnapshot, error) {
const command = "toolchains.decodeReply"
var result struct {
Status string `json:"status"`
Snapshot *ToolchainProviderSnapshot `json:"snapshot"`
Error *MarketplaceRejection `json:"error"`
}
if err := c.Execute(ctx, command, query, &result); err != nil {
return ToolchainProviderSnapshot{}, err
}
if result.Error != nil {
return ToolchainProviderSnapshot{}, result.Error
}
if result.Status != "ok" || result.Snapshot == nil {
return ToolchainProviderSnapshot{}, newParseError(command, "toolchains.decodeReply returned no snapshot", "")
}
return *result.Snapshot, nil
}
3 changes: 3 additions & 0 deletions desktop/internal/pluginbackend/pluginbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ type StartRequest struct {
// VcsProviderID selects a VCS provider the same way. It is empty for the
// other roles.
VcsProviderID string
// ToolchainProviders are the provider IDs from the approved backend manifest.
ToolchainProviders []string
// Role is the Core session role. Empty keeps the historical backend role;
// a build provider names "build" and a VCS provider "vcs".
Role string
Expand Down Expand Up @@ -422,6 +424,7 @@ func (r *Runner) Start(ctx context.Context, request StartRequest) (Session, erro
RootURI: request.RootURI,
WorkingDirectory: request.WorkingDirectory,
HostServices: granted,
ToolchainProviders: request.ToolchainProviders,
HostOptions: hostOptions(granted),
InitializationOptions: plan.InitializationOptions,
WorkspaceConfiguration: plan.WorkspaceConfiguration,
Expand Down
10 changes: 7 additions & 3 deletions desktop/internal/pluginhost/pluginhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ type Capabilities map[string][]int
// launches use the shared Core resolver. Version 1 adds a definition's
// category and audience, which group the tool on the Toolchains settings
// page.
// - toolchainProviders: the shared plugin backend discovers global and project
// installations and requirements on demand. Core validates each answer with
// native filesystem facts before the toolchain resolver can use it.
// - commandInstallers: plugin management reports the commands a
// systemCommand launch names but the machine lacks, and installs them with
// the plugin's tool after the user confirms the command line, the network
Expand Down Expand Up @@ -157,9 +160,9 @@ type Capabilities map[string][]int
// watching, authentication, history entry diffs, status in the project tree
// and the editor gutter, and lithe/vcs/execution console output.
//
// buildModelInputs, executionProviders, keymapImportProviders, packageTrust and
// toolchainProviders are not declared: nothing here serves
// them, so a plugin that needs one is not offered for installation.
// buildModelInputs, executionProviders, keymapImportProviders and packageTrust
// are not declared: nothing here serves them, so plugins requiring them are
// not offered for installation.
func Declared() Capabilities {
baseline := []string{
"backend",
Expand All @@ -178,6 +181,7 @@ func Declared() Capabilities {
"settings",
"sourceSettings",
"toolDefinitions",
"toolchainProviders",
"ui",
"vcsProviders",
}
Expand Down
Loading
Loading