Electron API And Ipc
Developmentelectron-api-and-ipcElectron API And Ipc is an Agent Skill for development published in the massCodeIO/massCode repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Use when changing massCode API routes, DTOs, IPC handlers, Electron bridges, or any renderer-to-main communication and storage-access boundaries.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/massCodeIO/massCode/blob/HEAD/.agents/skills/electron-api-and-ipc/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/electron-api-and-ipc, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Electron API And IPC
Overview
Все backend-возможности massCode живут в main process. Renderer получает доступ к данным и системным операциям только через Elysia API или IPC channels.
Renderer Access Rules
- В renderer для данных используй
import { api } from '~/renderer/services/api'. - В renderer для системных операций используй
ipc.invoke('channel:action', payload). - Electron API из renderer доступен только через
src/renderer/electron.ts. - Никогда не импортируй storage internals или backend-модули напрямую в renderer.
New API Endpoints
При добавлении нового endpoint:
- создай DTO в
src/main/api/dto/; - добавь route в
src/main/api/routes/; - запусти
pnpm api:generate, чтобы обновить клиент.
Не оставляй API-клиент рассинхронизированным с route/DTO изменениями.
IPC Conventions
- Для filesystem и system ops используй
ipc.invoke(...). - Каналы должны укладываться в семейства:
fs:*system:*db:*— legacy или migration flows, не основной путь для новой функциональностиmain-menu:*prettier:*spaces:*theme:*
Good Boundaries
- Renderer формирует intent и payload.
- Main/API работает с данными приложения, файловой системой и system APIs.
- Ответ возвращается обратно в renderer в виде DTO или IPC result, а не через shared mutable backend module.
Common Mistakes
- Тянуть backend-модуль напрямую в renderer ради “удобства”.
- Менять DTO/route без
pnpm api:generate. - Добавлять system/file behavior в renderer вместо IPC handler.
- Добавлять новые
db:*flows там, где задача должна идти через текущую API/IPC модель приложения. - Создавать ad-hoc каналы, которые не укладываются в существующие channel families.