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(skills): keep filesystem roots meaningful through the path fold
liuzixiang1739a9c3050f
diff --git a/apps/desktop/electron/main/plugin-workspace-contains.ts b/apps/desktop/electron/main/plugin-workspace-contains.tsindex fa28d22f4..72f9bb374 100644--- a/apps/desktop/electron/main/plugin-workspace-contains.ts+++ b/apps/desktop/electron/main/plugin-workspace-contains.ts@@ -5,20 +5,28 @@* forward-slash variant) — so both are unified before comparing: separators* fold to `/`, the Windows verbatim prefix (`\\?\X:\` in either spelling)* drops away, and comparison stays case-sensitive only on Linux, matching the- * worktree ref folding. Kept dependency free so its test can drive it- * directly.+ * worktree ref folding. A filesystem root (`/`, `C:/`) keeps its meaning+ * through the fold, so a workspace opened at a root still contains its plugin+ * folders. Kept dependency free so its test can drive it directly.*/export function pluginWorkspaceContains(workspacePath: string,pluginPath: string,): boolean {const fold = (value: string) => {- const unified = value.replace(/\\/g, "/").replace(/\/+$/, "");- const stripped = unified.replace(/^\/\/\?\/(?=[a-z]:\/)/i, "");- return process.platform === "linux" ? stripped : stripped.toLowerCase();+ const unified = value.replace(/\\/g, "/").replace(/^\/\/\?\/(?=[a-z]:\/)/i, "");+ const trimmed = unified.replace(/\/+$/, "");+ // A path of separators only is the filesystem root, not an empty path:+ // trimming it must not turn it into "nothing contains nothing".+ const rooted = trimmed === "" && unified.startsWith("/") ? "/" : trimmed;+ return process.platform === "linux" ? rooted : rooted.toLowerCase();};const workspace = fold(workspacePath);if (!workspace) return false;const plugin = fold(pluginPath);+ // The POSIX root contains every absolute path; `${workspace}/` would spell+ // "//" and match none of them. Windows drive roots keep their shape+ // (`c:` + `/…`), so they need no special case.+ if (workspace === "/") return plugin.startsWith("/");return plugin === workspace || plugin.startsWith(`${workspace}/`);}diff --git a/apps/desktop/test/plugin-workspace-contains.test.mjs b/apps/desktop/test/plugin-workspace-contains.test.mjsindex f6a66630a..634745663 100644--- a/apps/desktop/test/plugin-workspace-contains.test.mjs+++ b/apps/desktop/test/plugin-workspace-contains.test.mjs@@ -31,3 +31,24 @@ test("plugin workspace containment keeps the prefix boundary", () => {// Trailing separators on either side do not break the comparison.assert.equal(pluginWorkspaceContains("/home/dev/repo/", "/home/dev/repo/plugin"), true);});++test("a filesystem-root workspace still contains its plugin folders", () => {+ // Normalizing a bare root away would make it contain nothing at all, while+ // the prefix check it replaced matched every absolute path.+ assert.equal(pluginWorkspaceContains("/", "/tmp/plugins/example"), true);+ assert.equal(pluginWorkspaceContains("/", "/"), true);+ assert.equal(pluginWorkspaceContains("///", "/tmp/plugins/example"), true);+ assert.equal(pluginWorkspaceContains("/", "tmp/plugins/example"), false);++ // Drive roots keep their shape through the fold, so containment is the same+ // test as for any other folder.+ assert.equal(pluginWorkspaceContains("C:\\", "C:\\dev\\repo\\plugins\\p"), true);+ assert.equal(pluginWorkspaceContains("C:/", "C:/dev/repo/plugins/p"), true);+ assert.equal(pluginWorkspaceContains("C:/", "C:"), true);+ assert.equal(pluginWorkspaceContains("C:/", "D:/dev/repo/plugins/p"), false);+ // The verbatim drive root folds to the same root.+ assert.equal(pluginWorkspaceContains("//?/C:/", "C:\\dev\\repo\\plugins\\p"), true);+ // A root still respects the sibling boundary: nothing outranks it, but a+ // relative path is not inside it.+ assert.equal(pluginWorkspaceContains("C:/", "C:/dev"), true);+});