Agent Skills › openchamber/openchamber › desktop-shell

desktop-shell

GitHub

指导修改 Electron 主进程/预加载代码、桌面 IPC、原生窗口及菜单等。强调运行时边界划分、IPC 安全规范、Windows 后台进程管理及打包生命周期,确保前端与原生逻辑解耦及安全隔离。

.agents/skills/desktop-shell/SKILL.md openchamber/openchamber

触发场景

修改 Electron main 或 preload 代码 调整桌面 IPC 通信逻辑 配置 Windows 后台子进程启动 处理原生窗口、菜单或通知行为

安装

npx skills add openchamber/openchamber --skill desktop-shell -g -y
更多选项

非标准路径

npx skills add https://github.com/openchamber/openchamber/tree/main/.agents/skills/desktop-shell -g -y

不安装直接使用

npx skills use openchamber/openchamber@desktop-shell

指定 Agent (Claude Code)

npx skills add openchamber/openchamber --skill desktop-shell -a claude-code -g -y

安装 repo 全部 skill

npx skills add openchamber/openchamber --all -g -y

预览 repo 内 skill

npx skills add openchamber/openchamber --list

SKILL.md

Frontmatter
{
    "name": "desktop-shell",
    "description": "Use when changing Electron main\/preload code, desktop IPC, native windows, menus, dialogs, notifications, updater behavior, deep links, SSH or tunnels, child processes, packaged startup, or Windows process spawning, and when driving or inspecting the desktop window (dev or installed) over CDP."
}

Desktop Shell

Required Context

Read packages/electron/README.md and nearby packages/electron code before editing. Context gathering is complete when each changed behavior is assigned to main, preload, renderer/shared UI, or web/runtime ownership.

Load ui-api-decoupling when a native change adds or alters a renderer-facing capability, RuntimeAPIs, runtime auth/URL behavior, or shared bridge contract. This skill owns the Electron privilege boundary; ui-api-decoupling owns the shared UI/runtime contract.

Before editing behavior a user can reach, write the surface list from ui-api-decoupling, Name The Surfaces Before Editing: one line per runtime, including the ones this change appears to leave alone. A native-looking change is the usual place this gets skipped: a shutdown order, an updater handoff, or a window lifecycle reads as desktop-only while the sequence around it is shared, and the platform guard that is correct on its own becomes a trap when the rest of the sequence does not account for it.

Runtime Boundary

  • Electron boots @openchamber/web in the same Node process and loads the UI over loopback. Do not introduce a sidecar server process.
  • Keep renderer contracts and domain logic in packages/ui, server behavior in packages/web, and Electron focused on inherently native behavior: windows, menus, dialogs, notifications, updater, deep links, runtime host switching, privileged IPC, SSH, and tunnel lifecycle.
  • Electron is the desktop release target.

IPC And Security

Add a native capability the way packages/electron/README.md, IPC Pattern, orders it; the gate lives in main, never in the renderer. Shared UI code imports nothing from Electron.

Expose the narrowest payload and never expose filesystem, shell, tokens, or host secrets to remote pages.

Remote runtime pages must not gain local desktop privileges. Treat deep links, host imports, stored credentials, and runtime switching as trust-boundary operations that require explicit in-app confirmation before they change anything.

Windows Background Processes

Non-user-visible child processes open no console window on Windows.

  • Spawn the target executable directly with windowsHide: true.
  • Use stdio: 'ignore' for detached/background helpers and call unref() when they must outlive Electron.
  • Avoid cmd.exe /c, batch shims, taskkill, ping delays, and pipelines that create console grandchildren. windowsHide reliably controls only the directly spawned process.
  • For delayed work that must survive app exit, spawn one first-level hidden helper, such as powershell.exe -NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ...; perform delay and work inside that process with cmdlets.
  • Omit hidden-process behavior only for intentionally user-visible terminals or applications.

Packaging And Lifecycle

  • Keep native/external modules configured according to packages/electron/README.md and bundle-main.mjs.
  • Preserve startup, quit, updater, notification, and deep-link behavior across development and packaged builds.
  • Ensure cleanup tolerates partial startup and repeated shutdown signals.
  • Every quit path goes through prepareForQuit() (main.mjs), which flushes renderer storage before app.exit(): that exit skips the pages' unload handlers, and unwritten localStorage would be lost.
  • Do not infer readiness from stdout when an in-process callback or returned server handle exists.

Validation

Before judging any change to the update or quit/install sequence, read openchamber-change-discipline's references/updater-testing.md.

Auth and header bugs reproduce only in the installed app: only the packaged renderer (openchamber-ui://app) is cross-origin and attaches the client bearer (Authorization: Bearer oc_client_…); dev web and dev Electron run same-origin without it. To inspect the installed app, quit it and relaunch /Applications/OpenChamber.app/Contents/MacOS/OpenChamber --remote-debugging-port=9222, then talk CDP over the page's own webSocketDebuggerUrl from http://127.0.0.1:9222/json/list (a browser-level connectOverCDP times out). Its server answers on desktopLocalPort from ~/.config/openchamber/settings.json; logs are in ~/Library/Logs/OpenChamber/main.log.

To test the dev window the same way, start it with OPENCHAMBER_ELECTRON_REMOTE_DEBUGGING_PORT=9222 bun run electron:dev (Electron drops a plain --remote-debugging-port passed through the dev script; packaged builds ignore the variable) and use the same CDP route. Every dev window shares the OpenChamber Dev profile and its single-instance lock, so a second one exits at once while another is open; give yours its own with OPENCHAMBER_DESKTOP_USER_DATA_DIR="$(mktemp -d)" and remove that folder when you stop it. Stop the window by the pid of node ./packages/electron/scripts/electron-dev.mjs: the bash -c that bun run wraps it in does not pass the signal on. Runtime.evaluate reads page and React state, and Input.dispatchMouseEvent/Input.dispatchKeyEvent go through Chromium's real input pipeline, so they exercise hit-testing and focus the way a user's click does; a scripted element.click() skips both.

Run focused Electron tests and package checks. For startup, preload, routing, or packaging changes, completion requires both HMR development and bundled UI validation. For Windows process work, completion requires inspection of the complete process tree with no console flash; command success alone is insufficient.

版本历史

  • 6cd8058 当前 2026-11-03 06:03

    重构 Agent 文档以消除重复和矛盾,明确变更执行步骤及各类型代码的运行位置,优化了 desktop-shell 技能的上下文结构。

  • bf977d2 2026-10-19 13:04

    新增支持通过 CDP 连接开发环境窗口;修复退出时 localStorage 未刷新的问题。

  • 336e192 2026-09-22 17:57

    新增后台进程隐藏规范、打包生命周期要求;修正上游测试流程中关于关闭路径验证及跨平台差异的说明。

  • 2db90f7 2026-08-20 04:54

    细化上下文获取要求,明确运行时边界与 UI API 解耦规范,补充验证流程。

  • 74b1bd8 2026-07-25 10:36

同 Skill 集合

.agents/skills/changelog-authoring/SKILL.md
.agents/skills/clack-cli-patterns/SKILL.md
.agents/skills/communication-style/SKILL.md
.agents/skills/drag-to-reorder/SKILL.md
.agents/skills/enterprise-boundary/SKILL.md
.agents/skills/isolated-space-boundary/SKILL.md
.agents/skills/locale-ui-patterns/SKILL.md
.agents/skills/openchamber-change-discipline/SKILL.md
.agents/skills/opencode-v2/SKILL.md
.agents/skills/pr-review/SKILL.md
.agents/skills/relay-transport/SKILL.md
.agents/skills/rtl-layout/SKILL.md
.agents/skills/serve-sim/SKILL.md
.agents/skills/settings-ui-patterns/SKILL.md
.agents/skills/sync-state-invariants/SKILL.md
.agents/skills/theme-system/SKILL.md
.agents/skills/triage-issues/SKILL.md
.agents/skills/triage-prs/SKILL.md
.agents/skills/ui-api-decoupling/SKILL.md
.agents/skills/update-changelog/SKILL.md
.agents/skills/writing-for-agents/SKILL.md
.agents/skills/performance-engineering/SKILL.md

元信息

文件数
0
版本
6cd8058
Hash
1b50758a
收录时间
2026-07-25 10:36

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-06 02:07
浙ICP备14020137号-1