This file provides guidance to coding agent when working with code in this repository.
Pointer is a cross-platform desktop AI chat application built with Electron, React 19, and TypeScript. It features tree-structured conversation branches, multi-model support through any OpenAI-compatible API (OpenAI, DeepSeek, compatible gateways), and a VSCode-like interface with tabs, sidebar, and activity bar.
Requires Node.js >= 22.12 (Vitest 5 runs the test suite) and pnpm.
# Development
pnpm dev # Start development server with hot reload
pnpm start # Run preview mode
# Code quality
pnpm lint # Run ESLint
pnpm format # Run Prettier
pnpm typecheck # Type check both main and renderer processes
pnpm test # Run unit tests (domain + renderer mirror)
pnpm smoke:kernel # Boot the kernel in a temp dir and verify the full command/query chain
# Building
pnpm build # Build with type checking
pnpm build:win # Windows build
pnpm build:mac # macOS build
pnpm build:linux # Linux build
pnpm build:unpack # Build without packaging (for testing)
# Release
pnpm release # Build and publish to GitHub Releases
pnpm release:draft # Build for release testing (no publish)- Domain (
src/shared/domain/): pure TypeScript entities, invariants and algorithms (message tree, topics, workspace layout,.pointer.mdcodec, importers). No Electron, no IO. - Contracts (
src/shared/contracts/): the singleRuntimePortsurface — queries, commands, events. - Kernel (
src/main/runtime/): system of record. Owns persistence (atomic writes), the SQLite index, sessions, AI streaming, search, attachments, settings and API keys (stored in plaintext in the account'ssettings.json). Exposed to the renderer only throughsrc/main/ipc/runtimeIpc.ts. - Presentation (
src/renderer/src/): React UI holding view state plus a mirror of kernel state fed by events. It never touches paths, files or the filesystem. - Preload (
src/preload/): exposeswindow.runtime(query/command/subscribe),window.electronWindowandwindow.shortcutsonly.
Data flow: UI → services/* → stores/* → runtime/client → kernel command → kernel event →
mirror store → UI. See docs/architecture.md for the layering, data flow and storage layout.
runtime/ # 内核客户端与镜像装配(client.ts, bootstrap.ts, generation.ts)
components/
layout/ # MainLayout, ActivityBar, Sidebar, EditorArea, Tabs, TitleBar
editors/ # ChatEditor, SettingsEditor, ExportEditor, WelcomePage
panels/ # Explorer (conversation tree), Search
common/ # Reusable components
stores/ # Zustand mirrors + view state (messagesStore, pagesStore, settingsStore, etc.)
services/ # Thin wrappers that issue kernel commands (messagesService, pagesService, ...)
hooks/ # Custom hooks (useChat, useChatStreaming, usePages, etc.)
utils/ # Utilities including tab registry system
types/shared.ts # Re-export of domain + contract types used by the UI
features/ # Feature modules (export plugins, etc.)
-
Message Tree Structure: Three-level hierarchy - Page (conversation) → Message branches (for branching conversations) → Individual messages
-
Tab Registry System (
utils/tabRegistry.ts): Plugin-style registration for different tab types (chat, settings, export, welcome) -
State Management: Zustand stores hold view state and a mirror of kernel state; all writes go through kernel commands and return as events (no local persistence logic)
-
AI Streaming: The kernel owns the request lifecycle; the renderer only reacts to
chat.delta/chat.reasoning/chat.completedevents
- Single quotes, no semicolons, no trailing commas, 100 char line width, LF line endings
(see
.prettierrc.yaml) - Prefer Ant Design components and patterns
- Decompose into small, focused components
- Documentation language:
docs/andREADME.zh-CN.mdare Chinese;README.mdandAGENTS.mdare English; code comments are Chinese
| File | Purpose |
|---|---|
docs/architecture.md |
Layering, data flow, contracts, storage layout |
docs/auto-update-guide.md |
Auto-update behavior, commands/events, release flow |
docs/code-signing-guide.md |
Windows code signing, dev signature-check bypass |
| File | Purpose |
|---|---|
src/shared/domain/index.ts |
Domain entities, invariants, algorithms |
src/shared/contracts/queries.ts |
Query contract (read side) |
src/shared/contracts/commands.ts |
Command contract (write side) |
src/main/runtime/RuntimeCore.ts |
Kernel assembly, session switching, dispatch |
src/main/runtime/WorkspaceStore.ts |
Page tree, conversations, disk reconciliation |
src/main/runtime/ChatEngine.ts |
Streaming lifecycle and queue drain |
src/renderer/src/runtime/bootstrap.ts |
Kernel mirror wiring for the UI |
src/renderer/src/stores/messagesStore.ts |
Conversation mirror and commands |
src/renderer/src/hooks/useChat.ts |
Core chat logic hook |
src/renderer/src/utils/tabRegistry.ts |
Tab type registration system |