mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 09:12:29 +08:00
Initial GPT-5-high generated cursor rules
This commit is contained in:
16
.cursor/rules/api-client.mdc
Normal file
16
.cursor/rules/api-client.mdc
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
description: API client usage and streaming
|
||||
---
|
||||
|
||||
### API Client
|
||||
|
||||
- Use domain functions in `[service/index.ts](mdc:service/index.ts)` for app features.
|
||||
- Prefer `get/post/put/del` from `[service/base.ts](mdc:service/base.ts)`; they apply base options, timeout, and error toasts.
|
||||
- Set request bodies via `options.body`; it will be JSON-stringified automatically.
|
||||
- Add query via `options.params` on GET.
|
||||
- Downloads: set `Content-type` header to `application/octet-stream`.
|
||||
|
||||
### SSE Streaming
|
||||
|
||||
- For streaming responses, use `ssePost` from `[service/base.ts](mdc:service/base.ts)` and supply callbacks: `onData`, `onCompleted`, `onThought`, `onFile`, `onMessageEnd`, `onMessageReplace`, `onWorkflowStarted`, `onNodeStarted`, `onNodeFinished`, `onWorkflowFinished`, `onError`.
|
||||
- Chat messages helper: `sendChatMessage` in `[service/index.ts](mdc:service/index.ts)` preconfigures streaming.
|
||||
10
.cursor/rules/i18n.mdc
Normal file
10
.cursor/rules/i18n.mdc
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
description: i18n usage and locale resolution
|
||||
---
|
||||
|
||||
### i18n
|
||||
|
||||
- Server locale: `getLocaleOnServer()` reads cookie or negotiates from headers: `[i18n/server.ts](mdc:i18n/server.ts)`.
|
||||
- Client locale: use `getLocaleOnClient()` / `setLocaleOnClient()` in `[i18n/client.ts](mdc:i18n/client.ts)`; uses `LOCALE_COOKIE_NAME` from config.
|
||||
- Place translations in `i18n/lang/**`. Keep keys synchronized across locales.
|
||||
- Render `<html lang>` using the resolved locale in `[app/layout.tsx](mdc:app/layout.tsx)`.
|
||||
21
.cursor/rules/project-structure.mdc
Normal file
21
.cursor/rules/project-structure.mdc
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
### Project Structure Overview
|
||||
|
||||
- **App Router (Next.js 14)**: Entry is `app/layout.tsx` and `app/page.tsx`.
|
||||
- **API Routes**: Located under `app/api/**`. Server handlers live in `route.ts` files per folder.
|
||||
- **Components**: UI under `app/components/**` with feature folders (e.g., `chat`, `workflow`, `base`).
|
||||
- **Services (API client)**: Client-side HTTP/SSE utilities in `[service/base.ts](mdc:service/base.ts)` and domain methods in `[service/index.ts](mdc:service/index.ts)`.
|
||||
- **Config**: Global config in `[config/index.ts](mdc:config/index.ts)` and Next config in `[next.config.js](mdc:next.config.js)`.
|
||||
- **i18n**: Client/server helpers in `[i18n/client.ts](mdc:i18n/client.ts)` and `[i18n/server.ts](mdc:i18n/server.ts)`, with resources in `i18n/lang/**`.
|
||||
- **Styles**: Tailwind setup `[tailwind.config.js](mdc:tailwind.config.js)`, global styles under `app/styles/**`.
|
||||
|
||||
Key entrypoints:
|
||||
|
||||
- Layout: `[app/layout.tsx](mdc:app/layout.tsx)`
|
||||
- Home page: `[app/page.tsx](mdc:app/page.tsx)`
|
||||
- HTTP utilities: `[service/base.ts](mdc:service/base.ts)`
|
||||
- API domain functions: `[service/index.ts](mdc:service/index.ts)`
|
||||
- Internationalization: `[i18n/server.ts](mdc:i18n/server.ts)`, `[i18n/client.ts](mdc:i18n/client.ts)`
|
||||
20
.cursor/rules/typescript-react.mdc
Normal file
20
.cursor/rules/typescript-react.mdc
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
globs: *.ts,*.tsx
|
||||
---
|
||||
|
||||
### TypeScript/React Conventions
|
||||
|
||||
- **Strict TS**: `strict: true` in `tsconfig.json`. Avoid `any`. Prefer explicit function signatures for exports.
|
||||
- **Paths**: Use `@/*` alias (tsconfig `paths`) for absolute imports.
|
||||
- **React 18**: Prefer function components. Use `React.memo` only for measurable perf wins.
|
||||
- **Hooks**: Co-locate hooks under `hooks/**`. Keep hook names prefixed with `use`.
|
||||
- **App Router**: Server components by default. Mark client components with `'use client'` when needed.
|
||||
- **Styling**: Tailwind-first; SCSS only where necessary.
|
||||
- **Classnames**: Use `classnames` or `tailwind-merge` for conditional classes.
|
||||
- **Control Flow**: Early returns, handle edge cases first; avoid deep nesting.
|
||||
|
||||
### Next.js Notes
|
||||
|
||||
- Route handlers belong in `app/api/**/route.ts`.
|
||||
- Do not import server-only modules into client components.
|
||||
- Keep environment access to server files; avoid exposing secrets.
|
||||
11
.cursor/rules/ui-components.mdc
Normal file
11
.cursor/rules/ui-components.mdc
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
description: UI components and styling conventions
|
||||
---
|
||||
|
||||
### UI Components
|
||||
|
||||
- Component folders under `app/components/**`; keep base primitives in `base/**` (buttons, icons, inputs, uploader, etc.).
|
||||
- Larger features (chat, workflow) live in their own folders with `index.tsx` and submodules.
|
||||
- Prefer colocated `style.module.css` or Tailwind classes. Global styles in `app/styles/**`.
|
||||
- Use `app/components/base/toast` for error/display notifications.
|
||||
- Avoid unnecessary client components; mark with `'use client'` only when needed (state, effects, browser APIs).
|
||||
Reference in New Issue
Block a user