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(desktop): define dirname in ESM main bundle
vastsa6a0082eb366d
diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.tsindex 85b4f8c99..4ebae2d92 100644--- a/apps/desktop/electron.vite.config.ts+++ b/apps/desktop/electron.vite.config.ts@@ -53,6 +53,9 @@ export default defineConfig({define: {"process.env.WS_NO_BUFFER_UTIL": "\"1\"","process.env.WS_NO_UTF_8_VALIDATE": "\"1\"",+ // The main bundle is ESM (`type: module`), where Node does not provide+ // the CommonJS `__dirname` global used by Electron's relative asset paths.+ "__dirname": "import.meta.dirname",},build: {rollupOptions: {diff --git a/apps/desktop/test/runtime-build-contract.test.mjs b/apps/desktop/test/runtime-build-contract.test.mjsindex 3be20a2f5..a4a4e990d 100644--- a/apps/desktop/test/runtime-build-contract.test.mjs+++ b/apps/desktop/test/runtime-build-contract.test.mjs@@ -79,3 +79,8 @@ test("workspace packages keep their tsbuildinfo inside the output directory", as);}});++test("Electron main defines __dirname from its ESM output location", async () => {+ const config = await readFile(new URL("../electron.vite.config.ts", import.meta.url), "utf8");+ assert.match(config, /"__dirname"\s*:\s*"import\.meta\.dirname"/);+});