Back to Aionui

Development Guide

docs/contributing/development.md

1.9.258.3 KB
Original Source

Development Guide

Prerequisites

  • Node.js 22 or higher
  • bun — Package manager & runtime (install)
  • Python 3.11+ (for native module compilation)
  • prek — PR code checker (npm install -g @j178/prek)

Quick Start

bash
# Clone the repository
git clone https://github.com/iOfficeAI/AionUi.git
cd AionUi

# Install dependencies
bun install

# Start development server (Electron desktop mode)
bun start

Scripts Reference

Development

CommandDescription
bun startStart Electron app in development mode (desktop)
bun run start:multiStart a second Electron instance alongside an existing one (see Multi-Instance)
bun run cliAlias for bun start
bun run webuiStart in WebUI mode (browser-based, no Electron window)
bun run webui:remoteStart in WebUI mode with remote access enabled
bun run webui:prodStart WebUI in production mode
bun run webui:prod:remoteStart WebUI in production mode with remote access
bun run resetpassReset user password via CLI

Build & Distribution

CommandDescription
bun run packageBuild all processes (main, preload, renderer) to out/
bun run makeAlias for bun run package
bun run distBuild and package distributable for current platform
bun run dist:macBuild distributable for macOS
bun run dist:winBuild distributable for Windows
bun run dist:linuxBuild distributable for Linux
bun run build-macBuild macOS distributable for both arm64 and x64
bun run build-mac:arm64Build macOS distributable for Apple Silicon only
bun run build-mac:x64Build macOS distributable for Intel only
bun run build-winBuild Windows distributable
bun run build-win:arm64Build Windows distributable for ARM64
bun run build-win:x64Build Windows distributable for x64
bun run build-debBuild Linux (.deb) distributable
bun run buildAlias for bun run build-mac

Standalone Server (non-Electron)

CommandDescription
bun run build:renderer:webBuild renderer for standalone web deployment
bun run build:serverBuild standalone server bundle to dist-server/
bun run server:startRun standalone server in development mode
bun run server:start:remoteRun standalone server with remote access
bun run server:start:prodRun standalone server in production mode
bun run server:start:prod:remoteRun standalone server in production mode with remote access
bun run server:resetpassReset password via standalone server CLI
bun run server:resetpass:prodReset password via standalone server CLI (production)

Code Quality

CommandDescription
bun run lintCheck for lint issues (oxlint, read-only)
bun run lint:fixAuto-fix lint issues
bun run formatAuto-format code (oxfmt)
bun run format:checkCheck formatting without modifying files
bun run i18n:typesGenerate TypeScript types for i18n keys

Testing

CommandDescription
bun run testRun all unit tests (vitest)
bun run test:watchRun tests in watch mode
bun run test:coverageRun tests with coverage report
bun run test:contractRun contract tests
bun run test:integrationRun integration tests
bun run test:bunRun Bun-specific database driver tests
bun run test:e2eRun end-to-end tests (Playwright)
bun run test:packaged:i18nRun i18n integration tests against packaged build
bun run test:packaged:bunRun Bun packaged integration tests

Debug

CommandDescription
bun run debug:perfStart app with performance monitoring enabled
bun run debug:perf:reportGenerate performance report from collected data
bun run debug:mcpDebug MCP server connections
bun run debug:mcp:listList configured MCP servers
bun run debug:mcp:validateValidate MCP server configurations
bun run debug:custom-agentDebug custom agent connections

Multi-Instance Development

When you have two clones of the repository (e.g. AionUi and AionUi-refactor) and need to run both simultaneously, the second instance can be started with:

bash
bun run start:multi

This sets AIONUI_MULTI_INSTANCE=1, which:

  • Skips the Electron single-instance lock
  • Uses a separate userData directory (AionUi-Dev-2) to avoid database and config conflicts
  • Isolates data/config symlink paths (~/.aionui-dev-2, ~/.aionui-config-dev-2)
  • Vite renderer, CDP, and WebUI proxy ports auto-increment to avoid collisions

Note: The multi-instance WebUI defaults to port 25810 (instead of 25809). When accessing WebUI in a browser, use an incognito/private window for the second instance — both instances share the localhost cookie jar, and their JWT secrets differ, causing authentication failures if the same browser session is reused.

Code Checks (prek)

The project uses prek (a Rust implementation of pre-commit) for code checks, configured in .pre-commit-config.yaml:

bash
# Install prek
npm install -g @j178/prek

# Install git hooks (optional, auto-check before commit)
prek install

# Run checks on staged files
prek run

# Run checks on changes vs main (same as CI)
prek run --from-ref origin/main --to-ref HEAD

Build System

AionUi uses electron-vite for fast bundling:

  • Main process: bundled with Vite (ESM)
  • Renderer process: bundled with Vite (React + TypeScript)
  • Preload scripts: bundled with Vite

The build output goes to out/ directory:

  • out/main/ - Main process code
  • out/renderer/ - Renderer process code
  • out/preload/ - Preload scripts

Tech Stack

  • Electron - Cross-platform desktop framework
  • React 19 - UI framework
  • TypeScript - Type safety
  • Vite - Fast bundler (via electron-vite)
  • UnoCSS - Atomic CSS engine
  • better-sqlite3 - Local database
  • vitest - Testing framework