feat(core): initialize project skeleton with Electron + React + TypeScript

Set up the complete project foundation for ClawX, a graphical AI assistant:

- Electron main process with IPC handlers, menu, tray, and gateway management
- React renderer with routing, layout components, and page scaffolding
- Zustand state management for gateway, settings, channels, skills, chat, and cron
- shadcn/ui components with Tailwind CSS and CSS variable theming
- Build tooling with Vite, electron-builder, and TypeScript configuration
- Testing setup with Vitest and Playwright
- Development configurations (ESLint, Prettier, gitignore, env example)
This commit is contained in:
Haze
2026-02-05 23:09:17 +08:00
Unverified
parent 9442e5f77a
commit b8ab0208d0
71 changed files with 14086 additions and 3 deletions

74
src/types/channel.ts Normal file
View File

@@ -0,0 +1,74 @@
/**
* Channel Type Definitions
* Types for messaging channels (WhatsApp, Telegram, etc.)
*/
/**
* Supported channel types
*/
export type ChannelType = 'whatsapp' | 'telegram' | 'discord' | 'slack' | 'wechat';
/**
* Channel connection status
*/
export type ChannelStatus = 'connected' | 'disconnected' | 'connecting' | 'error';
/**
* Channel data structure
*/
export interface Channel {
id: string;
type: ChannelType;
name: string;
status: ChannelStatus;
lastActivity?: string;
error?: string;
avatar?: string;
metadata?: Record<string, unknown>;
}
/**
* Channel configuration for each type
*/
export interface ChannelConfig {
whatsapp: {
phoneNumber?: string;
};
telegram: {
botToken?: string;
chatId?: string;
};
discord: {
botToken?: string;
guildId?: string;
};
slack: {
botToken?: string;
appToken?: string;
};
wechat: {
appId?: string;
};
}
/**
* Channel icons mapping
*/
export const CHANNEL_ICONS: Record<ChannelType, string> = {
whatsapp: '📱',
telegram: '✈️',
discord: '🎮',
slack: '💼',
wechat: '💬',
};
/**
* Channel display names
*/
export const CHANNEL_NAMES: Record<ChannelType, string> = {
whatsapp: 'WhatsApp',
telegram: 'Telegram',
discord: 'Discord',
slack: 'Slack',
wechat: 'WeChat',
};

68
src/types/cron.ts Normal file
View File

@@ -0,0 +1,68 @@
/**
* Cron Job Type Definitions
* Types for scheduled tasks
*/
import { ChannelType } from './channel';
/**
* Cron job target (where to send the result)
*/
export interface CronJobTarget {
channelType: ChannelType;
channelId: string;
channelName: string;
}
/**
* Cron job last run info
*/
export interface CronJobLastRun {
time: string;
success: boolean;
error?: string;
duration?: number;
}
/**
* Cron job data structure
*/
export interface CronJob {
id: string;
name: string;
message: string;
schedule: string;
target: CronJobTarget;
enabled: boolean;
createdAt: string;
updatedAt: string;
lastRun?: CronJobLastRun;
nextRun?: string;
}
/**
* Input for creating a cron job
*/
export interface CronJobCreateInput {
name: string;
message: string;
schedule: string;
target: CronJobTarget;
enabled?: boolean;
}
/**
* Input for updating a cron job
*/
export interface CronJobUpdateInput {
name?: string;
message?: string;
schedule?: string;
target?: CronJobTarget;
enabled?: boolean;
}
/**
* Schedule type for UI picker
*/
export type ScheduleType = 'daily' | 'weekly' | 'monthly' | 'interval' | 'custom';

26
src/types/electron.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
/**
* Electron API Type Declarations
* Types for the APIs exposed via contextBridge
*/
export interface IpcRenderer {
invoke(channel: string, ...args: unknown[]): Promise<unknown>;
on(channel: string, callback: (...args: unknown[]) => void): (() => void) | void;
once(channel: string, callback: (...args: unknown[]) => void): void;
off(channel: string, callback?: (...args: unknown[]) => void): void;
}
export interface ElectronAPI {
ipcRenderer: IpcRenderer;
openExternal: (url: string) => Promise<void>;
platform: NodeJS.Platform;
isDev: boolean;
}
declare global {
interface Window {
electron: ElectronAPI;
}
}
export {};

25
src/types/gateway.ts Normal file
View File

@@ -0,0 +1,25 @@
/**
* Gateway Type Definitions
* Types for Gateway communication and data structures
*/
/**
* Gateway connection status
*/
export interface GatewayStatus {
state: 'stopped' | 'starting' | 'running' | 'error';
port: number;
pid?: number;
uptime?: number;
error?: string;
connectedAt?: number;
}
/**
* Gateway RPC response
*/
export interface GatewayRpcResponse<T = unknown> {
success: boolean;
result?: T;
error?: string;
}

64
src/types/skill.ts Normal file
View File

@@ -0,0 +1,64 @@
/**
* Skill Type Definitions
* Types for skills/plugins
*/
/**
* Skill category
*/
export type SkillCategory =
| 'productivity'
| 'developer'
| 'smart-home'
| 'media'
| 'communication'
| 'security'
| 'information'
| 'utility'
| 'custom';
/**
* Skill data structure
*/
export interface Skill {
id: string;
name: string;
description: string;
enabled: boolean;
category: SkillCategory;
icon?: string;
version?: string;
author?: string;
configurable?: boolean;
isCore?: boolean;
dependencies?: string[];
}
/**
* Skill bundle (preset skill collection)
*/
export interface SkillBundle {
id: string;
name: string;
nameZh: string;
description: string;
descriptionZh: string;
icon: string;
skills: string[];
recommended?: boolean;
}
/**
* Skill configuration schema
*/
export interface SkillConfigSchema {
type: 'object';
properties: Record<string, {
type: 'string' | 'number' | 'boolean' | 'array';
title?: string;
description?: string;
default?: unknown;
enum?: unknown[];
}>;
required?: string[];
}