Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions .github/workflows/rust-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ jobs:
# Code behind cfg(windows) compiles only for Windows. Checking it here
# finds its errors without a Windows runner; default features only,
# because the remote server feature targets Unix hosts. Clippy only
# checks and never links, so SQLite (bundled for the Motty import) is
# told to link a system library instead of compiling its C source,
# which needs the MSVC tools that a Linux runner does not have.
# checks and never links, so the C dependencies use host pkg-config
# metadata instead of compiling for MSVC on a Linux runner.
- name: Install Windows lint metadata
run: sudo apt-get install -y libzstd-dev
- name: Lint for Windows
env:
LIBSQLITE3_SYS_USE_PKG_CONFIG: "1"
ZSTD_SYS_USE_PKG_CONFIG: "1"
PKG_CONFIG_ALLOW_CROSS: "1"
run: |
read -ra packages <<< "$PACKAGES"
cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --target x86_64-pc-windows-msvc -- -D warnings
Expand Down
42 changes: 42 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ or removing a command fails until the table changes in the same commit.
| `plugins.editorActions.decode` | Validate independent action registration, collection or click results |
| `plugins.hostApi.describe` | Describe backend host methods and their required grants from Core's method table |
| `plugins.hostApi.authorize` | Check a method, service and current session grants using Core's capability rules; the host still checks session and resource ownership |
| `plugins.workflow` | Validate host workflow requests and project bounded inputs, pagination, and output |
| `plugins.editorProviders.decode` | Validate editor provider registrations and provider function results |
| `keymap.decodeImport` | Validate a normalized shortcut import against the host's action catalog |
| `keymap.planImportSources` | Plan the selected provider's declared shortcut source inputs |
Expand Down Expand Up @@ -600,6 +601,8 @@ or removing a command fails until the table changes in the same commit.
| `project.extractArchive` | Extract a downloaded project archive into the staging directory, refusing unsafe entries |
| `plugins.marketplace.validateIndex` | Validate a marketplace index and report each plugin's availability for one platform |
| `plugins.marketplace.resolveSource` | Resolve a user-entered marketplace source to the index and companion recommendations URLs to fetch |
| `plugins.marketplace.selectDelta` | Select an exact-base delta from a marketplace companion |
| `plugins.marketplace.applyDelta` | Rebuild a marketplace ZIP in caller-owned private staging |
| `plugins.marketplace.installReview` | List a package's permissions and programs, and those not yet approved |
| `plugins.marketplace.recommendForWorkspace` | Match sampled workspace files against marketplace recommendation catalogs and indexes |
| `workspace.snapshot` | Enumerate visible workspace nodes and relative file paths; `nestedWorktrees` lists linked worktrees checked out inside their own repository, which are left out of the tree, files, and search index; hidden folders, Core's own and the ones enabled plugins declare through `workspace.configureVisibility`, are skipped without being read; `includeTree: false` returns only `files` and a childless `root`; `files` (and the tree, when included) keep the lowercase traversal order that bounded consumers such as Windows Quick Open rely on, not the natural display order of `workspace.listDirectories` |
Expand Down Expand Up @@ -5453,7 +5456,21 @@ See the plugin contract's
[output link matchers](../../shared/plugins/contract/v1/README.md#output-link-matchers).


The `plugins.marketplace.*` commands are equally pure: hosts fetch indexes and
`resolveSource` also provides `deltasURL` beside the canonical and pinned
index URLs. `selectDelta` takes
`{index, pluginID, platform, repository, fromVersion, fromSHA256, toVersion, toSHA256, archiveURL}`
and returns `{status: "ok", patch}`, with `patch` set to null when the base and
target have no applicable delta. The index is the optional companion described
in the [plugin marketplace contract](../../shared/plugins/contract/v1/README.md#delta-archives).

`applyDelta` takes `{patch, basePath, patchPath, outputPath}` and returns
`{status: "ok", applied: true}` after verifying the base, patch and rebuilt ZIP.
The paths are local and absolute. The output path must be absent in the caller's
private staging directory. The caller removes staging on error or cancellation.
A malformed or mismatched selection or reconstruction uses `plugin.delta.invalid`.
Both commands are desktop-only Core commands and are not callable by a plugin.

Hosts fetch marketplace indexes and
archives and pass the parsed JSON. `validateIndex` accepts
`{ index, sourceKind: "official" | "thirdParty", platform, hostCapabilities? }`
and returns `{ status: "ok", index: { plugins, rejected } }` with per-entry
Expand Down
10 changes: 10 additions & 0 deletions rust/crates/core/src/protocol/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ pub enum PluginsCommand {
EditorProvidersDecode,
/// Validates and filters a marketplace index (`plugins.marketplace.validateIndex`).
MarketplaceValidateIndex,
/// Selects an optional, exact-base marketplace delta.
MarketplaceSelectDelta,
/// Rebuilds and verifies a marketplace ZIP in private staging.
MarketplaceApplyDelta,
/// Resolves a user-entered marketplace source URL (`plugins.marketplace.resolveSource`).
MarketplaceResolveSource,
/// Lists a package's permissions and programs before installation (`plugins.marketplace.installReview`).
Expand Down Expand Up @@ -1368,6 +1372,12 @@ impl CoreCommand {
"plugins.marketplace.validateIndex" => {
Some(Self::Plugins(PluginsCommand::MarketplaceValidateIndex))
}
"plugins.marketplace.selectDelta" => {
Some(Self::Plugins(PluginsCommand::MarketplaceSelectDelta))
}
"plugins.marketplace.applyDelta" => {
Some(Self::Plugins(PluginsCommand::MarketplaceApplyDelta))
}
"plugins.marketplace.resolveSource" => {
Some(Self::Plugins(PluginsCommand::MarketplaceResolveSource))
}
Expand Down
6 changes: 6 additions & 0 deletions rust/crates/core/src/runtime/dispatcher/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ pub(super) fn dispatch(
payload,
lithe_plugin_marketplace::validate_index_command,
),
PluginsCommand::MarketplaceSelectDelta => {
plugin_response(id, payload, lithe_plugin_marketplace::select_delta_command)
}
PluginsCommand::MarketplaceApplyDelta => {
plugin_response(id, payload, lithe_plugin_marketplace::apply_delta_command)
}
PluginsCommand::MarketplaceResolveSource => plugin_response(
id,
payload,
Expand Down
45 changes: 27 additions & 18 deletions rust/crates/platform/src/scoped_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Directory {
if matches!(component, std::path::Component::Prefix(_)) {
continue;
}
let handle = windows_open(&path, false)?;
let handle = windows_open(&path, WindowsOpen::Directory)?;
let info = metadata(handle.metadata()?);
if info.kind == Kind::Symlink {
return Err(link_refused());
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Directory {
#[cfg(windows)]
{
let path = self.path.join(name);
let handle = windows_open(&path, false)?;
let handle = windows_open(&path, WindowsOpen::Directory)?;
let info = metadata(handle.metadata()?);
if info.kind == Kind::Symlink {
return Err(link_refused());
Expand All @@ -174,7 +174,7 @@ impl Directory {
#[cfg(unix)]
let handle = unix_open(&self.handle, name, libc::O_NONBLOCK)?;
#[cfg(windows)]
let handle = windows_open(&self.path.join(name), true)?;
let handle = windows_open(&self.path.join(name), WindowsOpen::File)?;
let info = metadata(handle.metadata()?);
if info.kind == Kind::Symlink {
return Err(link_refused());
Expand Down Expand Up @@ -206,7 +206,7 @@ impl Directory {
}
#[cfg(windows)]
{
windows_open(&self.path.join(name), false)?
windows_open(&self.path.join(name), WindowsOpen::Metadata)?
.metadata()
.map(metadata)
}
Expand Down Expand Up @@ -382,24 +382,33 @@ unsafe fn errno() -> *mut i32 {
}

#[cfg(windows)]
fn windows_open(path: &Path, read: bool) -> io::Result<File> {
enum WindowsOpen {
Directory,
File,
Metadata,
}

#[cfg(windows)]
fn windows_open(path: &Path, purpose: WindowsOpen) -> io::Result<File> {
use std::os::windows::fs::OpenOptionsExt;
use windows_sys::Win32::Storage::FileSystem::{
FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, FILE_READ_ATTRIBUTES,
FILE_SHARE_READ, FILE_SHARE_WRITE,
FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_TRAVERSE,
};
let mut options = std::fs::OpenOptions::new();
if read {
options.read(true);
} else {
options.access_mode(FILE_READ_ATTRIBUTES);
match purpose {
// Attribute-only handles do not enforce sharing. Traversal makes the
// directory's rename share restriction effective without listing it.
WindowsOpen::Directory => options
.access_mode(FILE_READ_ATTRIBUTES | FILE_TRAVERSE)
.share_mode(FILE_SHARE_READ),
WindowsOpen::File => options
.read(true)
.share_mode(FILE_SHARE_READ | FILE_SHARE_WRITE),
WindowsOpen::Metadata => options
.access_mode(FILE_READ_ATTRIBUTES)
.share_mode(FILE_SHARE_READ),
}
options
.share_mode(if read {
FILE_SHARE_READ | FILE_SHARE_WRITE
} else {
FILE_SHARE_READ
})
.custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT)
.open(path)
.custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT)
.open(path)
}
2 changes: 2 additions & 0 deletions rust/crates/plugin-marketplace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ lithe-protocol = { path = "../protocol" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
url = "2.5"
sha2 = "0.10"
zstd = { version = "0.13", default-features = false }
Loading
Loading