Repository navigation
feat(api-11): 文件变更由 Core 完成,新建支持符号链接 - #184
Merged
Merged
Conversation
- 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 新增符号链接和路径写法用例
xiaoyumuxi
marked this pull request as ready for review
November 23, 2026 10:06
This was referenced Nov 23, 2026
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。接着已合入的 #183(API-11 保存与文件变更)做两件事:
workspace/create支持新建符号链接;文件变更的通用逻辑(参数检查、路径解析、磁盘操作)从桌面端搬进 Core。桌面端接入在另一个 PR,开出后在这里补链接。类型
workspace/create新增kind:"symlink";API-11 参数在 Core 严格检查;新增四个内核命令和两个内核错误码宿主方法
不新增宿主方法,只扩展已有方法的参数:
lithe/host/workspace/createkind:"symlink"和linkTarget)改动说明
符号链接(
workspace/create)kind:"symlink"和linkTarget(1–4096 字节,不含 NUL)。链接不带text;文件和文件夹带linkTarget是invalidParams。readFile、列表和editor/open仍做根目录检查,根目录外的文件不会因此可读;也不能穿过离开根目录的父目录新建任何东西。不新增读取链接的权限。/存成\;目标是已存在的目录就建目录链接,否则建文件链接;系统拒绝建链接(没开开发者模式、也不是管理员)时返回failed。参数严格检查(
plugin-rpc,路由前拒绝)host_requests.rs:API-11 七个方法从HostParams::Object改为各自的参数形状(DocumentSave、DocumentSaveAs、DocumentClose、WorkspaceCreate、WorkspaceMove、WorkspaceTrash),未知字段直接拒绝。host_params.rs:resource/target只能是{rootID,path}。/分隔,没有空段、.、..,最长 4096 字节;Windows 上不能原样保存的名字(CON、结尾的点或空格、\ : * ? " < > |)也是invalidParams。根目录本身不能作为条目。create的字段要和kind一致;text超过 128 KiB 返回limitExceeded。documentID必须是非空字符串,expectedVersion是非负整数。lib.rs新增 4 组测试。内核命令(桌面端调用,插件不能直接调)
workspace.createEntryworkspace.renameEntryworkspace.copyEntryworkspace.resolveEntrylithe-project新模块file_changes.rs;core/src/protocol/command.rs和core/src/runtime/dispatcher/workspace.rs接线;core/src/tests/file_changes.rs有 10 个集成测试(lithe-core为此加了lithe-platform开发依赖,用来在测试里建链接)。{ path, fullPath, kind },fullPath按桌面端传来的根目录拼写,和打开的文档用的路径一致。entry_not_found、entry_exists(lithe-protocol,application-boundary.md有说明);父目录解析到根目录外是permission_denied,其他系统错误是unknown,系统消息放在details。lithe-platformpaths::invalid_entry_path:“路径只有一种写法”的唯一实现,plugin-rpc和lithe-project共用。entries:rename_no_replace:macOS 用renamex_np+RENAME_EXCL,Linux 用renameat2+RENAME_NOREPLACE,文件系统不支持时退回先检查再重命名;Windows 用MoveFileExW不带替换标志。create_symlink:Unix 用symlink,Windows 按上面的规则选目录链接或文件链接。windows-sys依赖(锁文件里已有同一版本,没有新包)。lithe-platform-tests新增 4 个真机测试;Windows 上没有建链接权限(错误 1314)时跳过链接测试。lithe-remoterename_no_replace,现在改用lithe-platform的这一份,删掉 macOS、Linux、unix 三处副本。契约、文档与 SDK
workspace/create行、错误表、路径写法、符号链接一段。backend/function-protocol.json新增 3 个用例:新建符号链接、缺linkTarget、路径带.段。rust-core-api.md:命令表加四行,并加一段说明参数、返回值、平台行为和错误码。api-catalog.md(中英)、guides/plugin-backend-workspace.md(中英)、domains/backend.md(中英)补上符号链接。protocol-changelog.md新增一条;feat(plugins): 插件后端可保存、关闭文档和新建、重命名、复制、移到废纸篓(API-11) #183 那条保持原文,方法索引里workspace/create仍记 feat(plugins): 插件后端可保存、关闭文档和新建、重命名、复制、移到废纸篓(API-11) #183(没有新增方法)。create注释写明symlink和linkTarget;Node 的index.d.ts把参数按kind分成三种形状,类型测试检查符号链接必须带linkTarget、只有文件能带text。不变的部分
不新增能力版本、宿主方法、通知、协议版本或 SDK 版本,属于
pluginAPIVersion0 内的补充。验证
cargo fmt --all --checkcargo test --workspace --features lithe-remote/server,lithe-remote/motty(2660 个测试通过)cargo clippy --all-targets -D warnings:本机所有受影响的 crate;aarch64-unknown-linux-musl上的lithe-platform、lithe-plugin-rpc、lithe-remote(server);x86_64-pc-windows-msvc上的lithe-platform。Windows 真机建链接的行为(目录/文件链接、\)由 CI 的 Windows runner 跑lithe-platform-tests覆盖。node 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.shgo vet、go test ./...;Rust SDKcargo test;Nodenpm test、npm run test:types;Javamvn -o test