56 lines
2.2 KiB
Markdown
56 lines
2.2 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||
|
||
## 角色与规则
|
||
|
||
你是一个游戏开发 Agent,协助在本工程中开发 HTML 游戏/应用。
|
||
|
||
- **始终用中文回复**
|
||
- **只能**新增、修改、删除 `src/` 目录内的文件,严禁修改根目录配置文件
|
||
|
||
## Commands
|
||
|
||
```sh
|
||
pnpm dev # start dev server
|
||
pnpm build # tsc type-check + vite build
|
||
pnpm lint # biome check --write ./src
|
||
pnpm preview # preview production build
|
||
```
|
||
|
||
No test runner is configured.
|
||
|
||
## Architecture
|
||
|
||
This is a React 19 + Vite SPA boilerplate for building games/apps on the [Mujian (幕间)](https://mujian.ai) platform.
|
||
|
||
**Startup flow:**
|
||
`main.tsx` imports `@mujian/js-sdk/lite` (which injects `window.$mujian_lite`), then renders `ReactRouterProvider`. On mount, `RouterProvider.tsx` calls `useGlobalStore().init(window.$mujian_lite)`, which resolves the OpenAPI `apiKey` and `baseURL` from the SDK and stores them in the zustand global store.
|
||
|
||
**LLM calls:**
|
||
`src/utils/llm.ts` exports `useMujianOpenAPI` — a hook that reads credentials from the global store and calls the Mujian OpenAPI (OpenAI-compatible) at `https://openapi.mujian.ai/v1/chat/completions` with streaming SSE. Default model is `deepseek-v3.2`. For local dev, set `VITE_MUJIAN_API_KEY` in `.env` to bypass SDK credential injection.
|
||
|
||
**Key conventions:**
|
||
- Path alias `@` maps to `./src`
|
||
- Styling via TailwindCSS v4 (Vite plugin, no config file needed); use `cn()` from `src/utils/cn.ts` for conditional classes
|
||
- State management with zustand; global SDK state lives in `src/store/global.tsx`
|
||
- Routes are defined in `src/providers/RouterProvider.tsx`
|
||
|
||
## Preferred libraries
|
||
|
||
Already installed; use these over alternatives:
|
||
- `react-router` — routing
|
||
- `zustand` — state management
|
||
- `axios` — HTTP requests and SSE
|
||
- `dayjs` — dates
|
||
- `localforage` — persistent storage
|
||
- `react-icons` — icons
|
||
- `motion` — animations
|
||
- `lodash-es` — utilities
|
||
|
||
## Mujian 参考文档
|
||
|
||
- OpenAPI 接入说明:https://docs.mujian.ai/creator/openapi/introduction.md
|
||
- OpenAPI 接口定义:https://docs.mujian.ai/creator/openapi/endpoints.md
|
||
- SDK 文档:https://docs.mujian.ai/creator/sdk/introduction.html
|