mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 08:59:02 +08:00
Replace Yarn usage with pnpm in CI workflows to standardize package management and leverage pnpm's store/cache behavior. - Use pnpm/action-setup to install pnpm (v) instead of enabling corepack and preparing Yarn. - Retrieve pnpm store path and update cache actions to cache the pnpm store and use pnpm-lock.yaml for cache keys and restores. - Replace yarn commands with pnpm equivalents across workflows: install, i18n:sync/translate, format, build:* and tsx invocation. - Avoid committing lockfile changes by resetting pnpm-lock.yaml instead of yarn.lock when checking for changes. - Update install flags: use pnpm install --frozen-lockfile / --install semantics where appropriate. These changes unify dependency tooling, improve caching correctness, and ensure CI uses pnpm-specific lockfile and cache paths.
63 lines
3.4 KiB
Markdown
63 lines
3.4 KiB
Markdown
# AI Assistant Guide
|
|
|
|
This file provides guidance to AI coding assistants when working with code in this repository. Adherence to these guidelines is crucial for maintaining code quality and consistency.
|
|
|
|
## Guiding Principles (MUST FOLLOW)
|
|
|
|
- **Keep it clear**: Write code that is easy to read, maintain, and explain.
|
|
- **Match the house style**: Reuse existing patterns, naming, and conventions.
|
|
- **Search smart**: Prefer `ast-grep` for semantic queries; fall back to `rg`/`grep` when needed.
|
|
- **Log centrally**: Route all logging through `loggerService` with the right context—no `console.log`.
|
|
- **Research via subagent**: Lean on `subagent` for external docs, APIs, news, and references.
|
|
- **Always propose before executing**: Before making any changes, clearly explain your planned approach and wait for explicit user approval to ensure alignment and prevent unwanted modifications.
|
|
- **Lint, test, and format before completion**: Coding tasks are only complete after running `pnpm lint`, `pnpm test`, and `pnpm format` successfully.
|
|
- **Write conventional commits**: Commit small, focused changes using Conventional Commit messages (e.g., `feat:`, `fix:`, `refactor:`, `docs:`).
|
|
|
|
## Pull Request Workflow (CRITICAL)
|
|
|
|
When creating a Pull Request, you MUST:
|
|
|
|
1. **Read the PR template first**: Always read `.github/pull_request_template.md` before creating the PR
|
|
2. **Follow ALL template sections**: Structure the `--body` parameter to include every section from the template
|
|
3. **Never skip sections**: Include all sections even if marking them as N/A or "None"
|
|
4. **Use proper formatting**: Match the template's markdown structure exactly (headings, checkboxes, code blocks)
|
|
|
|
## Development Commands
|
|
|
|
- **Install**: `pnpm install` - Install all project dependencies
|
|
- **Development**: `pnpm dev` - Runs Electron app in development mode with hot reload
|
|
- **Debug**: `pnpm debug` - Starts with debugging enabled, use `chrome://inspect` to attach debugger
|
|
- **Build Check**: `pnpm build:check` - **REQUIRED** before commits (lint + test + typecheck)
|
|
- If having i18n sort issues, run `pnpm i18n:sync` first to sync template
|
|
- If having formatting issues, run `pnpm format` first
|
|
- **Test**: `pnpm test` - Run all tests (Vitest) across main and renderer processes
|
|
- **Single Test**:
|
|
- `pnpm test:main` - Run tests for main process only
|
|
- `pnpm test:renderer` - Run tests for renderer process only
|
|
- **Lint**: `pnpm lint` - Fix linting issues and run TypeScript type checking
|
|
- **Format**: `pnpm format` - Auto-format code using Biome
|
|
|
|
## Project Architecture
|
|
|
|
### Electron Structure
|
|
|
|
- **Main Process** (`src/main/`): Node.js backend with services (MCP, Knowledge, Storage, etc.)
|
|
- **Renderer Process** (`src/renderer/`): React UI with Redux state management
|
|
- **Preload Scripts** (`src/preload/`): Secure IPC bridge
|
|
|
|
### Key Components
|
|
|
|
- **AI Core** (`src/renderer/src/aiCore/`): Middleware pipeline for multiple AI providers.
|
|
- **Services** (`src/main/services/`): MCPService, KnowledgeService, WindowService, etc.
|
|
- **Build System**: Electron-Vite with experimental rolldown-vite, pnpm workspaces.
|
|
- **State Management**: Redux Toolkit (`src/renderer/src/store/`) for predictable state.
|
|
|
|
### Logging
|
|
|
|
```typescript
|
|
import { loggerService } from "@logger";
|
|
const logger = loggerService.withContext("moduleName");
|
|
// Renderer: loggerService.initWindowSource('windowName') first
|
|
logger.info("message", CONTEXT);
|
|
```
|