Repository navigation
feat(plugins): 插件后端可保存、关闭文档和新建、重命名、复制、移到废纸篓(API-11) - #183
Merged
Merged
Conversation
- 新增宿主方法 documents/save、saveAs、close(新权限 documents.save)和 workspace/create、rename、copy、trash(新权限 workspace.files.write)。每个权限只授予 自己的方法,聚合的 workspace 授权和 documents.read 都不授予它们。 - 宿主经文档所有者保存;close 先保存再关闭,从不丢弃修改;目标已存在时失败、从不覆盖; trash 只移到系统废纸篓;需要用户选择的情形直接拒绝,不弹询问。 - 新增失败码 plugin.host.alreadyExists(-32080)和 plugin.host.diskChanged(-32081), 中转与宿主错误表保持一码一义。 - 契约 README 新增“保存文档与改动文件”一节,清单 schema、fixture、API 总表、领域页、 后端指南和协议更新记录同步;四个官方 SDK 新增 7 个方法的封装和两个失败码。
xiaoyumuxi
marked this pull request as ready for review
November 23, 2026 09:00
1 task done
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 23, 2026
* feat(api-11): 文件变更由 Core 完成,新建支持符号链接 - plugin-rpc 严格检查 API-11 七个方法的参数:路径只有一种写法(无空、`.`、`..` 段, Windows 不能保存的名字也拒绝),移动不出根目录也不进自身,create 的字段必须与 kind 一致 - 新增内核命令 workspace.createEntry、renameEntry、copyEntry、resolveEntry 和错误码 entry_not_found、entry_exists;路径检查、不覆盖的重命名、只改大小写的重命名、 复制时链接保持为链接、失败回滚都在 lithe-project 里完成 - lithe-platform 新增 entries 模块(rename_no_replace、create_symlink), remote 服务端改用这份实现,不再各自保留一份 - workspace/create 支持 kind:"symlink" + linkTarget,原样保存目标,不放宽读取检查 - 契约 README、Core API 文档、API 总表、指南、更新记录和四个 SDK 同步更新, fixture 新增符号链接和路径写法用例 * docs(changelog): 符号链接与 Core 文件变更单独记一条,#183 条目恢复原文 * docs(changelog): 补上 PR 编号 #184
1 task done
This was referenced Nov 28, 2026
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 29, 2026
* docs(plugins): 协议更新记录把已合入的 PR 移进时间线并回填日期(#222) “待合入”一节的 20 条记录(含 #224)对应的 PR 都已合入 main,按 UTC 合入日期改成时间线表格行,原文逐句保留,只删去“合入日期在合并时补齐” 之类的占位句;#193 已在时间线里,删去重复的待合入条目。新增 2026-11-24、 2026-11-22 两个日期分组。 - 回填“按协议查首次出现”的市场增量索引 schemaVersion 0(#187)、 toolchainProviders 1 与 litheToolchains 1(#182),以及“宿主方法 (按 API 编号)”里 #194、#190、#183、#151 的 18 个方法日期。 - 补录改了契约却没有登记的 #177、#117、#26。 - #207 的修改人按 PR 作者改为 devin-ai-integration[bot]。 - 时间线表头和维护说明统一用“改动”;转义 #133 行内代码里的竖线, 避免表格多出一列。 * docs(plugins): 已有宿主方法加字段也在方法表补行,统一方法表写法(#222) “宿主方法(按 API 编号)”表给 5 个 PR 补了 13 行,都是给已有方法或通知加字段、改校验时漏登记的: - #151:workspace/listContexts、workspace/getContext(authority 新增 platform),functions/invoke(转发远程工作区上下文的调用) - #184:API-11 的 7 个方法(路由前严格校验参数;workspace/create 的 kind 新增 symlink 与 linkTarget) - #188:editor/registerProviders(新增 colorDecorations) - #198:editor/registerActions(actionIcons 新增 4 个导航图标 token) - #224:agents/didPrompt(有附件时带 attachments) 统一写法:方法列只写方法名,补了什么写在协议列的括号里(#193 的 openHTML、openExternal,#23、#128 的 run/start,#128 的 prepareRun);同一个方法的各行排在一起,首次记录在前。 表格说明、维护第 3 步和 API PR 提交指南第 4 步写明:给已有方法或通知加参数、返回字段或取值,或改执行、校验行为,都在索引另加一行;API 总表不加行,用途、权限或协议变了就改原来那一行。
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.
关联 Issue
没有单独的 Issue。对应 macOS 插件 API 实施计划的 API-11(保存与文件变更),计划里原来是“未做”。桌面端实现在另一个 PR,开出后在这里补链接。
类型
新增宿主方法
lithe/host/documents/savelithe/host/documents/saveAslithe/host/documents/closelithe/host/workspace/createlithe/host/workspace/renamelithe/host/workspace/copylithe/host/workspace/trash改动说明
权限
documents.save授予documents/save、saveAs、close;workspace.files.write授予workspace/create、rename、copy、trash。workspace服务授权和documents.read)不授予这些方法,已经安装的插件不会因此多出写权限。plugin-rpc的新测试锁住这一点。行为规则(契约 README 新增“Saving documents and changing files”一节)
saveAs、create、rename、copy的目标已存在时返回plugin.host.alreadyExists。close先保存,保存失败就不关闭。trash只移到系统废纸篓。rename和trash先保存其下打开的文档,保存失败就什么都不动。plugin.host.diskChanged,不写入。preconditionFailed;磁盘冲突 →diskChanged。invalidParams。workspace/stat读回结果。plugin.host.authorityUnsupported。失败码
plugin.host.alreadyExists(-32080)和plugin.host.diskChanged(-32081)。号码此前没人用,failures.rs映射并透传,宿主错误表保持一码一义(SDK 里现为 25 项)。Core 代码
plugin-rpc:host_requests.rs加 7 行方法表,都用HostParams::Object;这是第一次用到它,所以去掉了它的dead_code豁免。lib.rs加两个权限常量、两个失败码常量和测试。failures.rs映射两个失败码。rust/fixtures/plugins/host-api-v1.json新增 4 个授权用例。契约与 fixture
backend/function-protocol.json新增 4 个宿主请求用例和 2 个失败码用例。四个官方 SDK
index.d.ts类型和类型测试。diskChanged和alreadyExists的处理方式。文档
api-catalog.md:domains/editor.md、domains/backend.md和guides/plugin-backend-workspace.md(中英)补上权限、方法和失败码。protocol-changelog.md新增条目和“宿主方法(按 API 编号)”7 行索引。不变的部分
不新增能力版本、通知或协议版本,属于
pluginAPIVersion0 内的补充。验证
cargo fmt --all --checkcargo test --workspace --features lithe-remote/server,lithe-remote/mottynode shared/plugins/scripts/verify-docs.mjsnode shared/plugins/scripts/sdk-e2e.mjsnode scripts/rust-core/verify-platform-tests.mjsscripts/rust-core/verify-rust-core-comments.shgofmt、go vet、go test ./...cargo testnpm test、npm run test:typesmvn -o -pl plugin-sdk test