Imported from LemmaHQ/lemma (
desktop/AGENTS.md). Install upstream withnpx skills add LemmaHQ/lemma --skill desktop. Copyright stays with the author.
AGENTS.md — Desktop shell
English | 中文
These rules supplement the repo-wide conventions; the TypeScript rules apply here.
Engine and renderer
- The renderer is the web client.
npm run buildbuildsweb/intoweb-dist/, then type-checks the desktop sources withtsc; change the UI inweb/.main.tsservesweb-dist/underapp://lemma/and answers any path without a file extension withindex.html, so the web client routes by path as it does in a browser. The window opens while the engine starts;connectEngine()waits for it, and a failed start replaces the page with the error. Git ignoresweb-dist/,out/, and.vite/. src/engine.tsruns the engine in an Electron utility process.src/engine-host.tsis that process's entry: it loads thelemma-desktopaddon, opens the engine over Electron'suserDatadirectory, and reportsready, orfailedwith the reason. Unpackaged builds load the addon fromtarget/<profile>/, whereLEMMA_ENGINE_PROFILEselects the profile (defaultdebug); packaged builds load it from the resources directory.- The page talks to the engine over the engine port, a
MessagePortthat bypasses the main process. OnconnectEngine(),main.tsopens aMessageChannelMainand hands one end to the engine process and the other to the page;src/serve-engine-port.tsserves requests on the engine end. When the engine exits,main.tstells the page, whose pending and later requests fail. src/preload.tsimplementswindow.lemmaDesktop, whose types live in@lemma/desktop-bridge;web/src/platform/is its only consumer.src/gen/theme-colors.tscarries the window colors: the background, sidebar, and foreground of each theme, generated from design/tokens.json. Git ignores it;npm run lint,test, andbuildgenerate it first.src/main.tsreads the titlebar and window background colors from it.LEMMA_DEBUG_PORTenables Chromium remote debugging.
Commands
just desktop-dev # build the engine addon, then launch Electron
just desktop-lint-check # oxlint; desktop-lint applies fixes
just desktop-fmt-check # prettier --check; desktop-fmt formats
just desktop-test # vitest
just desktop-cov # vitest coverage
just desktop-package # release engine addon, renderer build, electron-forge package