Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(plugins): keep fallback packages in the manager data root
zszz33a5d9ebf5db9
diff --git a/crates/host-core/src/plugins/marketplace.rs b/crates/host-core/src/plugins/marketplace.rsindex 33d7fced7..cfc61503c 100644--- a/crates/host-core/src/plugins/marketplace.rs+++ b/crates/host-core/src/plugins/marketplace.rs@@ -178,7 +178,7 @@ impl PluginManager {if let Some(parent) = path.parent() {fs::create_dir_all(parent)?;}- let catalog = built_in_catalog();+ let catalog = built_in_catalog(&self.data_dir);fs::write(&path, serde_json::to_string_pretty(&catalog)?)?;self.materialize_local_package_urls(&catalog)?;let _ = remote_err;@@ -367,7 +367,7 @@ impl PluginManager {}}- let catalog = built_in_catalog();+ let catalog = built_in_catalog(&self.data_dir);self.materialize_local_package_urls(&catalog)?;Ok(catalog)}diff --git a/crates/host-core/src/plugins/marketplace/catalog.rs b/crates/host-core/src/plugins/marketplace/catalog.rsindex f3233922f..9cbef9731 100644--- a/crates/host-core/src/plugins/marketplace/catalog.rs+++ b/crates/host-core/src/plugins/marketplace/catalog.rs@@ -1,13 +1,6 @@use super::super::*;-pub(crate) fn built_in_catalog() -> MarketCatalogFile {- let data_dir = std::env::var("PI_DESKTOP_DATA_DIR")- .map(PathBuf::from)- .unwrap_or_else(|_| {- dirs::home_dir()- .unwrap_or_else(|| PathBuf::from("."))- .join(".pi-desktop")- });+pub(crate) fn built_in_catalog(data_dir: &Path) -> MarketCatalogFile {let package_dir = data_dir.join("plugins/market/packages");let hello_path = package_dir.join("demo.hello-0.2.0.piplug");let notes_path = package_dir.join("demo.workspace-notes-0.1.0.piplug");diff --git a/crates/host-core/src/plugins/tests.rs b/crates/host-core/src/plugins/tests.rsindex 3c77c21bd..ef468c578 100644--- a/crates/host-core/src/plugins/tests.rs+++ b/crates/host-core/src/plugins/tests.rs@@ -81,7 +81,7 @@ fn marketplace_install_refreshes_catalog_before_checksum_verification() {let package_path = dir.path().join("fresh-demo.hello.piplug");fs::write(&package_path, &package_bytes).unwrap();- let mut remote = built_in_catalog();+ let mut remote = built_in_catalog(dir.path());let remote_version = &mut remote.plugins[0].versions[0];remote_version.url = format!("file://{}", package_path.to_string_lossy());remote_version.shasum = sha256_hex(&package_bytes);@@ -261,7 +261,7 @@ fn announced_version_without_a_package_is_visible_but_not_installable() {.unwrap();// The publisher announced 0.9.0 but has not uploaded its package.- let mut catalog = built_in_catalog();+ let mut catalog = built_in_catalog(dir.path());let announced = MarketVersion {version: "0.9.0".into(),published_at: "2026-08-13T00:00:00Z".into(),@@ -317,7 +317,7 @@ fn silent_update_check_uses_cached_catalog_without_refreshing_remote() {mgr.install_from_market("demo.hello", None, true, false, None).unwrap();- let mut cached = built_in_catalog();+ let mut cached = built_in_catalog(dir.path());cached.plugins[0].versions[0].version = "0.3.0".into();fs::write(mgr.catalog_path(),@@ -609,7 +609,7 @@ fn switching_source_ignores_the_previous_providers_snapshot() {// A snapshot carrying a plugin the built-in catalog does not have,// written while a different provider was selected.- let mut foreign = built_in_catalog();+ let mut foreign = built_in_catalog(dir.path());foreign.provider_id = "mirror".into();foreign.plugins.truncate(1);foreign.plugins[0].id = "mirror.only".into();@@ -2088,10 +2088,21 @@ fn an_install_reports_progress_and_honours_a_cancel() {with_local_market(|| {let dir = tempdir().unwrap();+ // The manager's directory owns its packages, even when another host+ // or test changes the process-wide default directory.+ let other = tempdir().unwrap();unsafe {- std::env::set_var("PI_DESKTOP_DATA_DIR", dir.path());+ std::env::set_var("PI_DESKTOP_DATA_DIR", other.path());}let mut mgr = PluginManager::new(dir.path(), MarketChannel::Official, None);+ let catalog: MarketCatalogFile =+ serde_json::from_str(&fs::read_to_string(mgr.catalog_path()).unwrap()).unwrap();+ for plugin in &catalog.plugins {+ for version in &plugin.versions {+ let local = version.url.strip_prefix("file://").unwrap();+ assert!(Path::new(local).starts_with(dir.path()));+ }+ }let mut log = InstallLog::default();let installed = mgrdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex b6a2bac64..8dcf6a72b 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -13693,6 +13693,12 @@ plugin-form fixtures in an isolated temporary directory at runtime.- **Milestone**: M6+- **Status**: Draft+- **Local fallback regression**: Set the process default data directory to a+ different temporary root, then create a plugin manager with its own root.+ All bundled fallback package URLs must stay beneath the manager's root;+ installing the bundled package must still report byte progress, validate its+ size and checksum, and preserve cancellation behavior.+#### E2E-PLUGIN-cancel-during-download-installs-nothing: Cancelling during the download stops the install, leaves nothing installed, and closes the dialog without an error- **Preconditions**: An official-channel install of a package large enough or a mirror slow enough that the download phase lasts, a way to answer `market.cancelInstall`, and a view of the plugin directory, the install cache, and the Installed list.diff --git a/docs/spec/07-plugins/11-plugin-storage-isolation.md b/docs/spec/07-plugins/11-plugin-storage-isolation.mdindex 594d80e5a..889d5bc38 100644--- a/docs/spec/07-plugins/11-plugin-storage-isolation.md+++ b/docs/spec/07-plugins/11-plugin-storage-isolation.md@@ -19,6 +19,12 @@ Isolate plugin data from the host's core data to avoid cross-contamination and u└── ...```+Bundled marketplace fallback packages use the owning plugin manager's data+root (`plugins/market/packages`), just like its catalog and download cache.+Catalog construction never re-reads the process-wide `PI_DESKTOP_DATA_DIR`;+independent host instances must not share package paths through that mutable+default. Package size and checksum validation remain mandatory.+## 3. registry.json (logical model)```tsdiff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 83c41cf43..1f374c1d0 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -8016,6 +8016,12 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixture- **里程碑**:M6+- **状态**:草稿+- **Local fallback regression**: Set the process default data directory to a+ different temporary root, then create a plugin manager with its own root.+ All bundled fallback package URLs must stay beneath the manager's root;+ installing the bundled package must still report byte progress, validate its+ size and checksum, and preserve cancellation behavior.+#### E2E-PLUGIN-cancel-during-download-installs-nothing:在下载期间取消会停止安装、不留下任何已安装内容,并让对话框静默关闭- **先决条件**:一次官方渠道安装,其安装包足够大或镜像足够慢,使下载阶段持续一段时间;能够应答 `market.cancelInstall`;同时可以查看插件目录、安装缓存与已安装列表。diff --git a/docs/zh-CN/spec/07-plugins/11-plugin-storage-isolation.md b/docs/zh-CN/spec/07-plugins/11-plugin-storage-isolation.mdindex e13883cea..13e741dd3 100644--- a/docs/zh-CN/spec/07-plugins/11-plugin-storage-isolation.md+++ b/docs/zh-CN/spec/07-plugins/11-plugin-storage-isolation.md@@ -22,6 +22,12 @@└── ...```+Bundled marketplace fallback packages use the owning plugin manager's data+root (`plugins/market/packages`), just like its catalog and download cache.+Catalog construction never re-reads the process-wide `PI_DESKTOP_DATA_DIR`;+independent host instances must not share package paths through that mutable+default. Package size and checksum validation remain mandatory.+## 3. registry.json(逻辑模型)```ts