@lobehub/lobehub 2.0.0-next.353 → 2.0.0-next.354

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.agents/skills/add-provider-doc/SKILL.md +90 -0
  2. package/.agents/skills/add-setting-env/SKILL.md +106 -0
  3. package/.agents/skills/debug/SKILL.md +66 -0
  4. package/.agents/skills/desktop/SKILL.md +78 -0
  5. package/.agents/skills/desktop/references/feature-implementation.md +99 -0
  6. package/.agents/skills/desktop/references/local-tools.md +133 -0
  7. package/.agents/skills/desktop/references/menu-config.md +103 -0
  8. package/.agents/skills/desktop/references/window-management.md +143 -0
  9. package/.agents/skills/drizzle/SKILL.md +129 -0
  10. package/.agents/skills/drizzle/references/db-migrations.md +50 -0
  11. package/.agents/skills/hotkey/SKILL.md +90 -0
  12. package/{.cursor/rules/i18n.mdc → .agents/skills/i18n/SKILL.md} +14 -23
  13. package/.agents/skills/linear/SKILL.md +51 -0
  14. package/.agents/skills/microcopy/SKILL.md +83 -0
  15. package/.agents/skills/modal/SKILL.md +102 -0
  16. package/{.cursor/rules/project-structure.mdc → .agents/skills/project-overview/SKILL.md} +65 -37
  17. package/.agents/skills/react/SKILL.md +73 -0
  18. package/.agents/skills/react/references/layout-kit.md +100 -0
  19. package/.agents/skills/recent-data/SKILL.md +108 -0
  20. package/.agents/skills/testing/SKILL.md +89 -0
  21. package/.agents/skills/testing/references/agent-runtime-e2e.md +126 -0
  22. package/.agents/skills/testing/references/db-model-test.md +124 -0
  23. package/.agents/skills/testing/references/desktop-controller-test.md +124 -0
  24. package/.agents/skills/testing/references/electron-ipc-test.md +63 -0
  25. package/.agents/skills/testing/references/zustand-store-action-test.md +150 -0
  26. package/.agents/skills/typescript/SKILL.md +52 -0
  27. package/.agents/skills/zustand/SKILL.md +78 -0
  28. package/.agents/skills/zustand/references/action-patterns.md +125 -0
  29. package/.agents/skills/zustand/references/slice-organization.md +125 -0
  30. package/AGENTS.md +42 -55
  31. package/CHANGELOG.md +33 -0
  32. package/CLAUDE.md +57 -46
  33. package/GEMINI.md +47 -39
  34. package/changelog/v1.json +9 -0
  35. package/package.json +1 -1
  36. package/src/features/FileViewer/Renderer/PDF/index.tsx +2 -3
  37. package/src/features/ShareModal/SharePdf/PdfPreview.tsx +1 -2
  38. package/src/libs/pdfjs/index.tsx +25 -0
  39. package/src/store/test-coverage.md +5 -5
  40. package/.cursor/rules/add-provider-doc.mdc +0 -183
  41. package/.cursor/rules/add-setting-env.mdc +0 -175
  42. package/.cursor/rules/cursor-rules.mdc +0 -28
  43. package/.cursor/rules/db-migrations.mdc +0 -46
  44. package/.cursor/rules/debug-usage.mdc +0 -86
  45. package/.cursor/rules/desktop-controller-tests.mdc +0 -189
  46. package/.cursor/rules/desktop-feature-implementation.mdc +0 -155
  47. package/.cursor/rules/desktop-local-tools-implement.mdc +0 -81
  48. package/.cursor/rules/desktop-menu-configuration.mdc +0 -209
  49. package/.cursor/rules/desktop-window-management.mdc +0 -301
  50. package/.cursor/rules/drizzle-schema-style-guide.mdc +0 -218
  51. package/.cursor/rules/hotkey.mdc +0 -162
  52. package/.cursor/rules/linear.mdc +0 -53
  53. package/.cursor/rules/microcopy-cn.mdc +0 -158
  54. package/.cursor/rules/microcopy-en.mdc +0 -148
  55. package/.cursor/rules/modal-imperative.mdc +0 -162
  56. package/.cursor/rules/packages/react-layout-kit.mdc +0 -122
  57. package/.cursor/rules/project-introduce.mdc +0 -36
  58. package/.cursor/rules/react.mdc +0 -169
  59. package/.cursor/rules/recent-data-usage.mdc +0 -139
  60. package/.cursor/rules/rules-index.mdc +0 -44
  61. package/.cursor/rules/testing-guide/agent-runtime-e2e.mdc +0 -285
  62. package/.cursor/rules/testing-guide/db-model-test.mdc +0 -455
  63. package/.cursor/rules/testing-guide/electron-ipc-test.mdc +0 -80
  64. package/.cursor/rules/testing-guide/testing-guide.mdc +0 -534
  65. package/.cursor/rules/testing-guide/zustand-store-action-test.mdc +0 -574
  66. package/.cursor/rules/typescript.mdc +0 -55
  67. package/.cursor/rules/zustand-action-patterns.mdc +0 -328
  68. package/.cursor/rules/zustand-slice-organization.mdc +0 -308
  69. package/src/libs/pdfjs/pdf.worker.ts +0 -1
  70. package/src/libs/pdfjs/worker.ts +0 -12
  71. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/AGENTS.md +0 -0
  72. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/SKILL.md +0 -0
  73. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/advanced-event-handler-refs.md +0 -0
  74. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/advanced-use-latest.md +0 -0
  75. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-api-routes.md +0 -0
  76. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-defer-await.md +0 -0
  77. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-dependencies.md +0 -0
  78. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-parallel.md +0 -0
  79. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-suspense-boundaries.md +0 -0
  80. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-barrel-imports.md +0 -0
  81. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-conditional.md +0 -0
  82. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-defer-third-party.md +0 -0
  83. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-dynamic-imports.md +0 -0
  84. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-preload.md +0 -0
  85. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-event-listeners.md +0 -0
  86. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-localstorage-schema.md +0 -0
  87. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-passive-event-listeners.md +0 -0
  88. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-swr-dedup.md +0 -0
  89. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-batch-dom-css.md +0 -0
  90. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-function-results.md +0 -0
  91. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-property-access.md +0 -0
  92. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-storage.md +0 -0
  93. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-combine-iterations.md +0 -0
  94. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-early-exit.md +0 -0
  95. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-hoist-regexp.md +0 -0
  96. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-index-maps.md +0 -0
  97. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-length-check-first.md +0 -0
  98. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-min-max-loop.md +0 -0
  99. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-set-map-lookups.md +0 -0
  100. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-tosorted-immutable.md +0 -0
  101. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-activity.md +0 -0
  102. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-animate-svg-wrapper.md +0 -0
  103. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-conditional-render.md +0 -0
  104. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-content-visibility.md +0 -0
  105. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-hoist-jsx.md +0 -0
  106. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-hydration-no-flicker.md +0 -0
  107. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-svg-precision.md +0 -0
  108. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-defer-reads.md +0 -0
  109. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-dependencies.md +0 -0
  110. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-derived-state.md +0 -0
  111. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-functional-setstate.md +0 -0
  112. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-lazy-state-init.md +0 -0
  113. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-memo.md +0 -0
  114. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-transitions.md +0 -0
  115. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-after-nonblocking.md +0 -0
  116. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-cache-lru.md +0 -0
  117. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-cache-react.md +0 -0
  118. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-parallel-fetching.md +0 -0
  119. /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-serialization.md +0 -0
package/GEMINI.md CHANGED
@@ -1,64 +1,72 @@
1
1
  # GEMINI.md
2
2
 
3
- This document serves as a shared guideline for all team members when using Gemini CLI in this repository.
3
+ Guidelines for using Gemini CLI in this LobeChat repository.
4
4
 
5
5
  ## Tech Stack
6
6
 
7
- read @.cursor/rules/project-introduce.mdc
8
-
9
- ## Directory Structure
10
-
11
- read @.cursor/rules/project-structure.mdc
7
+ - Next.js 16 + React 19 + TypeScript
8
+ - SPA inside Next.js with `react-router-dom`
9
+ - `@lobehub/ui`, antd for components; antd-style for CSS-in-JS
10
+ - react-i18next for i18n; zustand for state management
11
+ - SWR for data fetching; TRPC for type-safe backend
12
+ - Drizzle ORM with PostgreSQL; Vitest for testing
13
+
14
+ ## Project Structure
15
+
16
+ ```
17
+ lobe-chat/
18
+ ├── apps/desktop/ # Electron desktop app
19
+ ├── packages/ # Shared packages (@lobechat/*)
20
+ │ ├── database/ # Database schemas, models, repositories
21
+ │ ├── agent-runtime/ # Agent runtime
22
+ │ └── ...
23
+ ├── src/
24
+ │ ├── app/ # Next.js app router
25
+ │ ├── store/ # Zustand stores
26
+ │ ├── services/ # Client services
27
+ │ ├── server/ # Server services and routers
28
+ │ └── ...
29
+ └── e2e/ # E2E tests (Cucumber + Playwright)
30
+ ```
12
31
 
13
32
  ## Development
14
33
 
15
34
  ### Git Workflow
16
35
 
17
- - use rebase for git pull
18
- - git commit message should prefix with gitmoji
19
- - git branch name format template: <type>/<feature-name>
20
- - use .github/PULL_REQUEST_TEMPLATE.md to generate pull request description
21
- - PR titles starting with `✨ feat/` or `🐛 fix` will trigger the release workflow upon merge. Only use these prefixes for significant user-facing feature changes or bug fixes
36
+ - Use rebase for `git pull`
37
+ - Commit messages: prefix with gitmoji
38
+ - Branch format: `<type>/<feature-name>`
39
+ - PR titles with `✨ feat/` or `🐛 fix` trigger releases
22
40
 
23
41
  ### Package Management
24
42
 
25
- This repository adopts a monorepo structure.
26
-
27
- - Use `pnpm` as the primary package manager for dependency management
28
- - Use `bun` to run npm scripts
29
- - Use `bunx` to run executable npm packages
30
-
31
- ### TypeScript Code Style Guide
32
-
33
- see @.cursor/rules/typescript.mdc
43
+ - `pnpm` for dependency management
44
+ - `bun` to run npm scripts
45
+ - `bunx` for executable npm packages
34
46
 
35
47
  ### Testing
36
48
 
37
- - **Required Rule**: read `.cursor/rules/testing-guide/testing-guide.mdc` before writing tests
38
- - **Command**:
39
- - web: `bunx vitest run --silent='passed-only' '[file-path-pattern]'`
40
- - packages(eg: database): `cd packages/database && bunx vitest run --silent='passed-only' '[file-path-pattern]'`
41
-
42
- **Important**:
43
-
44
- - wrap the file path in single quotes to avoid shell expansion
45
- - Never run `bun run test` etc to run tests, this will run all tests and cost about 10mins
46
- - If trying to fix the same test twice, but still failed, stop and ask for help.
49
+ ```bash
50
+ # Run specific test (NEVER run `bun run test` - takes ~10 minutes)
51
+ bunx vitest run --silent='passed-only' '[file-path]'
47
52
 
48
- ### Typecheck
53
+ # Database package
54
+ cd packages/database && bunx vitest run --silent='passed-only' '[file]'
55
+ ```
49
56
 
50
- - use `bun run type-check` to check type errors.
57
+ - Tests must pass type check: `bun run type-check`
58
+ - After 2 failed fix attempts, stop and ask for help
51
59
 
52
60
  ### i18n
53
61
 
54
- - **Keys**: Add to `src/locales/default/namespace.ts`
55
- - **Dev**: Translate `locales/zh-CN/namespace.json` and `locales/en-US/namespace.json` locales file only for dev preview
56
- - DON'T run `pnpm i18n`, let CI auto handle it
62
+ - Add keys to `src/locales/default/namespace.ts`
63
+ - For dev preview: translate `locales/zh-CN/` and `locales/en-US/`
64
+ - Don't run `pnpm i18n` - CI handles it
57
65
 
58
- ## 🚨 Quality Checks
66
+ ## Quality Checks
59
67
 
60
- **MANDATORY**: After completing code changes, always run `mcp__vscode-mcp__get_diagnostics` on the modified files to identify any errors introduced by your changes and fix them.
68
+ **MANDATORY**: After completing code changes, run diagnostics on modified files to identify and fix any errors.
61
69
 
62
- ## Rules Index
70
+ ## Skills (Auto-loaded)
63
71
 
64
- Some useful project rules are listed in @.cursor/rules/rules-index.mdc
72
+ Skills are available in `.agents/skills/` directory. See CLAUDE.md for the full list.
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Migrate AI Rules to Claude Code Skills."
6
+ ]
7
+ },
8
+ "date": "2026-01-23",
9
+ "version": "2.0.0-next.354"
10
+ },
2
11
  {
3
12
  "children": {},
4
13
  "date": "2026-01-23",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.353",
3
+ "version": "2.0.0-next.354",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -2,12 +2,11 @@
2
2
 
3
3
  import { Flexbox } from '@lobehub/ui';
4
4
  import { Fragment, memo, useCallback, useState } from 'react';
5
- import { Document, Page, pdfjs } from 'react-pdf';
6
5
  import 'react-pdf/dist/Page/AnnotationLayer.css';
7
6
  import 'react-pdf/dist/Page/TextLayer.css';
8
7
 
9
8
  import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
10
- import '@/libs/pdfjs/worker';
9
+ import { Document, Page, pdfjs } from '@/libs/pdfjs';
11
10
  import { lambdaQuery } from '@/libs/trpc/client';
12
11
 
13
12
  import HighlightLayer from './HighlightLayer';
@@ -71,7 +70,7 @@ const PDFViewer = memo<PDFViewerProps>(({ url, fileId }) => {
71
70
  onLoadSuccess={onDocumentLoadSuccess}
72
71
  options={options}
73
72
  >
74
- {Array.from({ length: numPages }, (el, index) => {
73
+ {Array.from({ length: numPages }, (_, index) => {
75
74
  const width = containerWidth ? Math.min(containerWidth, maxWidth) : maxWidth;
76
75
 
77
76
  return (
@@ -7,10 +7,9 @@ import { createStaticStyles, cx } from 'antd-style';
7
7
  import { ChevronLeft, ChevronRight, Expand, FileText } from 'lucide-react';
8
8
  import { memo, useState } from 'react';
9
9
  import { useTranslation } from 'react-i18next';
10
- import { Document, Page } from 'react-pdf';
11
10
 
12
11
  import { useIsMobile } from '@/hooks/useIsMobile';
13
- import '@/libs/pdfjs/worker';
12
+ import { Document, Page } from '@/libs/pdfjs';
14
13
 
15
14
  import { containerStyles } from '../style';
16
15
 
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+
3
+ import type { ComponentProps } from 'react';
4
+ import { Document as PdfDocument, Page as PdfPage, pdfjs } from 'react-pdf';
5
+
6
+ const workerSrc = `https://registry.npmmirror.com/pdfjs-dist/${pdfjs.version}/files/build/pdf.worker.min.mjs`;
7
+
8
+ function ensureWorker() {
9
+ if (!pdfjs.GlobalWorkerOptions.workerSrc) {
10
+ pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
11
+ }
12
+ }
13
+
14
+ export type DocumentProps = ComponentProps<typeof PdfDocument>;
15
+ export type PageProps = ComponentProps<typeof PdfPage>;
16
+
17
+ export const Document = (props: DocumentProps) => {
18
+ ensureWorker();
19
+ return <PdfDocument {...props} />;
20
+ };
21
+
22
+
23
+
24
+
25
+ export {Page, pdfjs} from 'react-pdf';
@@ -35,7 +35,7 @@ All 40 action files in the store now have comprehensive test coverage!
35
35
 
36
36
  All store action tests should follow the patterns documented in:
37
37
 
38
- - **Main Guide**: `@.cursor/rules/testing-guide/zustand-store-action-test.mdc`
38
+ - **Main Guide**: `.agents/skills/testing/references/zustand-store-action-test.md`
39
39
 
40
40
  Key principles:
41
41
 
@@ -141,7 +141,7 @@ For files with multiple action files to test, use the Task tool to create subage
141
141
  **Example subagent prompt**:
142
142
 
143
143
  ```
144
- Write comprehensive tests for src/store/discover/slices/plugin/action.ts following @.cursor/rules/testing-guide/zustand-store-action-test.mdc.
144
+ Write comprehensive tests for src/store/discover/slices/plugin/action.ts following .agents/skills/testing/references/zustand-store-action-test.md.
145
145
 
146
146
  Requirements:
147
147
  1. Write tests covering all actions in the file
@@ -315,7 +315,7 @@ Create 5 subagents, one for each action file:
315
315
  Task({
316
316
  subagent_type: 'general-purpose',
317
317
  description: 'Test plugin action',
318
- prompt: `Write comprehensive tests for src/store/discover/slices/plugin/action.ts following @.cursor/rules/testing-guide/zustand-store-action-test.mdc.
318
+ prompt: `Write comprehensive tests for src/store/discover/slices/plugin/action.ts following .agents/skills/testing/references/zustand-store-action-test.md.
319
319
 
320
320
  Requirements:
321
321
  1. Write tests covering all actions (usePluginCategories, usePluginDetail, usePluginList, usePluginIdentifiers)
@@ -330,7 +330,7 @@ DO NOT commit changes or update test-coverage.md.`,
330
330
  Task({
331
331
  subagent_type: 'general-purpose',
332
332
  description: 'Test mcp action',
333
- prompt: `Write comprehensive tests for src/store/discover/slices/mcp/action.ts following @.cursor/rules/testing-guide/zustand-store-action-test.mdc.
333
+ prompt: `Write comprehensive tests for src/store/discover/slices/mcp/action.ts following .agents/skills/testing/references/zustand-store-action-test.md.
334
334
 
335
335
  Requirements:
336
336
  1. Write tests covering all actions (useFetchMcpDetail, useFetchMcpList, useMcpCategories)
@@ -561,7 +561,7 @@ bunx eslint src/store/[domain]/
561
561
  - 25 action files already have comprehensive tests (62.5% coverage)
562
562
  - 742 tests written across 80 test files
563
563
  - Well-tested stores: agent, chat (partial), file (partial), image, session, tool, user, global, aiInfra (partial)
564
- - Following zustand testing best practices from `@.cursor/rules/testing-guide/zustand-store-action-test.mdc`
564
+ - Following zustand testing best practices from `.agents/skills/testing/references/zustand-store-action-test.md`
565
565
 
566
566
  ## Notes
567
567
 
@@ -1,183 +0,0 @@
1
- ---
2
- description: Complete guide for adding a new AI provider documentation to LobeChat
3
- alwaysApply: false
4
- ---
5
-
6
- # Adding New AI Provider Documentation
7
-
8
- This document provides a step-by-step guide for adding documentation for a new AI provider to LobeChat, based on the complete workflow used for adding providers like BFL (Black Forest Labs) and FAL.
9
-
10
- ## Overview
11
-
12
- Adding a new provider requires creating both user-facing documentation and technical configuration files. The process involves:
13
-
14
- 1. Creating usage documentation (EN + CN)
15
- 2. Adding environment variable documentation (EN + CN)
16
- 3. Updating Docker configuration files
17
- 4. Updating .env.example file
18
- 5. Preparing image resources
19
-
20
- ## Step 1: Create Provider Usage Documentation
21
-
22
- Create user-facing documentation that explains how to use the new provider.
23
-
24
- ### Required Files
25
-
26
- Create both English and Chinese versions:
27
- - `docs/usage/providers/{provider-name}.mdx` (English)
28
- - `docs/usage/providers/{provider-name}.zh-CN.mdx` (Chinese)
29
-
30
- ### Documentation Structure
31
-
32
- Follow the structure and format used in existing provider documentation. For reference, see:
33
- - `docs/usage/providers/fal.mdx` (English template)
34
- - `docs/usage/providers/fal.zh-CN.mdx` (Chinese template)
35
-
36
- ### Key Requirements
37
-
38
- - **Images**: Prepare 5-6 screenshots showing the process
39
- - **Cover Image**: Create or obtain a cover image for the provider
40
- - **Accurate URLs**: Use real registration and dashboard URLs
41
- - **Service Type**: Specify whether it's for image generation, text generation, etc.
42
- - **Pricing Warning**: Include pricing information callout
43
-
44
- ### Important Notes
45
-
46
- - **🔒 API Key Security**: Never include real API keys in documentation. Always use placeholder format (e.g., `bfl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`)
47
- - **🖼️ Image Hosting**: Use LobeHub's CDN for all images: `hub-apac-1.lobeobjects.space`
48
-
49
- ## Step 2: Update Environment Variables Documentation
50
-
51
- Add the new provider's environment variables to the self-hosting documentation.
52
-
53
- ### Files to Update
54
-
55
- - `docs/self-hosting/environment-variables/model-provider.mdx` (English)
56
- - `docs/self-hosting/environment-variables/model-provider.zh-CN.mdx` (Chinese)
57
-
58
- ### Content to Add
59
-
60
- Add two sections for each provider:
61
-
62
- ```markdown
63
- ### `{PROVIDER}_API_KEY`
64
-
65
- - Type: Required
66
- - Description: This is the API key you applied for in the {Provider Name} service.
67
- - Default: -
68
- - Example: `{api-key-format-example}`
69
-
70
- ### `{PROVIDER}_MODEL_LIST`
71
-
72
- - Type: Optional
73
- - Description: Used to control the {Provider Name} model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model. Separate multiple entries with commas. The definition syntax follows the same rules as other providers' model lists.
74
- - Default: `-`
75
- - Example: `-all,+{model-id-1},+{model-id-2}={display-name}`
76
-
77
- The above example disables all models first, then enables `{model-id-1}` and `{model-id-2}` (displayed as `{display-name}`).
78
-
79
- [model-list]: /docs/self-hosting/advanced/model-list
80
- ```
81
-
82
- ### Important Notes
83
-
84
- - **API Key Format**: Use proper UUID format for examples (e.g., `12345678-1234-1234-1234-123456789abc`)
85
- - **Real Model IDs**: Use actual model IDs from the codebase, not placeholders
86
- - **Consistent Naming**: Follow the pattern `{PROVIDER}_API_KEY` and `{PROVIDER}_MODEL_LIST`
87
-
88
- ## Step 3: Update Docker Configuration Files
89
-
90
- Add environment variables to all Docker configuration files to ensure the provider works in containerized deployments.
91
-
92
- ### Files to Update
93
-
94
- All Dockerfile variants must be updated:
95
- - `Dockerfile`
96
- - `Dockerfile.database`
97
- - `Dockerfile.pglite`
98
-
99
- ### Changes Required
100
-
101
- Add the new provider's environment variables at the **end** of the ENV section, just before the final line:
102
-
103
- ```dockerfile
104
- # Previous providers...
105
- # 302.AI
106
- AI302_API_KEY="" AI302_MODEL_LIST="" \
107
- # {New Provider 1}
108
- {PROVIDER1}_API_KEY="" {PROVIDER1}_MODEL_LIST="" \
109
- # {New Provider 2}
110
- {PROVIDER2}_API_KEY="" {PROVIDER2}_MODEL_LIST=""
111
- ```
112
-
113
- ### Important Rules
114
-
115
- - **Position**: Add new providers at the **end** of the list
116
- - **Ordering**: When adding multiple providers, use alphabetical order (e.g., FAL before BFL)
117
- - **Consistency**: Maintain identical ordering across all Dockerfile variants
118
- - **Format**: Follow the pattern `{PROVIDER}_API_KEY="" {PROVIDER}_MODEL_LIST="" \`
119
-
120
- ## Step 4: Update .env.example File
121
-
122
- Add example configuration entries to help users understand how to configure the provider locally.
123
-
124
- ### File to Update
125
-
126
- - `.env.example`
127
-
128
- ### Content to Add
129
-
130
- Add new sections before the "Market Service" section:
131
-
132
- ```bash
133
- ### {Provider Name} ###
134
-
135
- # {PROVIDER}_API_KEY={provider-prefix}-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
136
- ```
137
-
138
- ### Format Guidelines
139
-
140
- - **Section Header**: Use `### {Provider Name} ###` format
141
- - **Commented Example**: Use `#` to comment out the example
142
- - **Key Format**: Use appropriate prefix for the provider (e.g., `bfl-`, `fal-`, `sk-`)
143
- - **Position**: Add before the Market Service section
144
- - **Spacing**: Maintain consistent spacing with existing entries
145
-
146
- ## Step 5: Image Resources
147
-
148
- Prepare all necessary image resources for the documentation.
149
-
150
- ### Required Images
151
-
152
- 1. **Cover Image**: Provider logo or branded image
153
- 2. **API Dashboard Screenshots**: 3-4 screenshots showing API key creation process
154
- 3. **LobeChat Configuration Screenshots**: 2-3 screenshots showing provider setup in LobeChat
155
-
156
- ### Image Guidelines
157
-
158
- - **Quality**: Use high-resolution screenshots
159
- - **Consistency**: Maintain consistent styling across all screenshots
160
- - **Privacy**: Remove or blur any sensitive information
161
- - **Format**: Use PNG format for screenshots
162
- - **Hosting**: Use LobeHub's CDN (`hub-apac-1.lobeobjects.space`) for all images
163
-
164
- ## Checklist
165
-
166
- Before submitting your provider documentation:
167
-
168
- - [ ] Created both English and Chinese usage documentation
169
- - [ ] Added environment variable documentation (EN + CN)
170
- - [ ] Updated all 3 Dockerfile variants with consistent ordering
171
- - [ ] Updated .env.example with proper key format
172
- - [ ] Prepared all required screenshots and images
173
- - [ ] Used actual model IDs from the codebase
174
- - [ ] Verified no real API keys are included in documentation
175
- - [ ] Used LobeHub CDN for all image hosting
176
- - [ ] Tested the documentation for clarity and accuracy
177
-
178
- ## Reference
179
-
180
- This guide was created based on the implementation of BFL (Black Forest Labs) provider documentation. For a complete example, refer to:
181
- - Commits: `d2da03e1a` (documentation) and `6a2e95868` (environment variables)
182
- - Files: `docs/usage/providers/bfl.mdx`, `docs/usage/providers/bfl.zh-CN.mdx`
183
- - PR: Current branch `tj/feat/bfl-docs`
@@ -1,175 +0,0 @@
1
- ---
2
- description: Guide for adding environment variables to configure user settings
3
- alwaysApply: false
4
- ---
5
-
6
- # Adding Environment Variable for User Settings
7
-
8
- Add server-side environment variables to configure default values for user settings.
9
-
10
- **Priority**: User Custom > Server Env Var > Hardcoded Default
11
-
12
- ## Steps
13
-
14
- ### 1. Define Environment Variable
15
-
16
- Create `src/envs/<domain>.ts`:
17
-
18
- ```typescript
19
- import { createEnv } from '@t3-oss/env-nextjs';
20
- import { z } from 'zod';
21
-
22
- export const get<Domain>Config = () => {
23
- return createEnv({
24
- server: {
25
- YOUR_ENV_VAR: z.coerce.number().min(MIN).max(MAX).optional(),
26
- },
27
- runtimeEnv: {
28
- YOUR_ENV_VAR: process.env.YOUR_ENV_VAR,
29
- },
30
- });
31
- };
32
-
33
- export const <domain>Env = get<Domain>Config();
34
- ```
35
-
36
- ### 2. Update Type (Optional)
37
-
38
- **Skip this step if the domain field already exists in `GlobalServerConfig`.**
39
-
40
- Add to `packages/types/src/serverConfig.ts`:
41
-
42
- ```typescript
43
- export interface GlobalServerConfig {
44
- <domain>?: {
45
- <settingName>?: <type>;
46
- };
47
- }
48
- ```
49
-
50
- **Prefer reusing existing types** from `packages/types/src/user/settings` with `PartialDeep`:
51
-
52
- ```typescript
53
- import { User<Domain>Config } from './user/settings';
54
-
55
- export interface GlobalServerConfig {
56
- <domain>?: PartialDeep<User<Domain>Config>;
57
- }
58
- ```
59
-
60
- ### 3. Assemble Server Config (Optional)
61
-
62
- **Skip this step if the domain field already exists in server config.**
63
-
64
- In `src/server/globalConfig/index.ts`:
65
-
66
- ```typescript
67
- import { <domain>Env } from '@/envs/<domain>';
68
- import { cleanObject } from '@/utils/object';
69
-
70
- export const getServerGlobalConfig = async () => {
71
- const config: GlobalServerConfig = {
72
- // ...
73
- <domain>: cleanObject({
74
- <settingName>: <domain>Env.YOUR_ENV_VAR,
75
- }),
76
- };
77
- return config;
78
- };
79
- ```
80
-
81
- If the domain already exists, just add the new field to the existing `cleanObject()`:
82
-
83
- ```typescript
84
- <domain>: cleanObject({
85
- existingField: <domain>Env.EXISTING_VAR,
86
- <settingName>: <domain>Env.YOUR_ENV_VAR, // Add this line
87
- }),
88
- ```
89
-
90
- ### 4. Merge to User Store (Optional)
91
-
92
- **Skip this step if the domain field already exists in `serverSettings`.**
93
-
94
- In `src/store/user/slices/common/action.ts`, add to `serverSettings`:
95
-
96
- ```typescript
97
- const serverSettings: PartialDeep<UserSettings> = {
98
- defaultAgent: serverConfig.defaultAgent,
99
- <domain>: serverConfig.<domain>, // Add this line
100
- // ...
101
- };
102
- ```
103
-
104
- ### 5. Update .env.example
105
-
106
- ```bash
107
- # <Description> (range/options, default: X)
108
- # YOUR_ENV_VAR=<example>
109
- ```
110
-
111
- ### 6. Update Documentation
112
-
113
- Update both English and Chinese documentation:
114
- - `docs/self-hosting/environment-variables/basic.mdx`
115
- - `docs/self-hosting/environment-variables/basic.zh-CN.mdx`
116
-
117
- Add new section or subsection with environment variable details (type, description, default, example, range/constraints).
118
-
119
- ## Type Reuse
120
-
121
- **Prefer reusing existing types** from `packages/types/src/user/settings` instead of defining inline types in `serverConfig.ts`.
122
-
123
- ```typescript
124
- // ✅ Good - reuse existing type
125
- import { UserImageConfig } from './user/settings';
126
-
127
- export interface GlobalServerConfig {
128
- image?: PartialDeep<UserImageConfig>;
129
- }
130
-
131
- // ❌ Bad - inline type definition
132
- export interface GlobalServerConfig {
133
- image?: {
134
- defaultImageNum?: number;
135
- };
136
- }
137
- ```
138
-
139
- ## Example: AI_IMAGE_DEFAULT_IMAGE_NUM
140
-
141
- ```typescript
142
- // src/envs/image.ts
143
- export const getImageConfig = () => {
144
- return createEnv({
145
- server: {
146
- AI_IMAGE_DEFAULT_IMAGE_NUM: z.coerce.number().min(1).max(20).optional(),
147
- },
148
- runtimeEnv: {
149
- AI_IMAGE_DEFAULT_IMAGE_NUM: process.env.AI_IMAGE_DEFAULT_IMAGE_NUM,
150
- },
151
- });
152
- };
153
-
154
- // packages/types/src/serverConfig.ts
155
- import { UserImageConfig } from './user/settings';
156
-
157
- export interface GlobalServerConfig {
158
- image?: PartialDeep<UserImageConfig>;
159
- }
160
-
161
- // src/server/globalConfig/index.ts
162
- image: cleanObject({
163
- defaultImageNum: imageEnv.AI_IMAGE_DEFAULT_IMAGE_NUM,
164
- }),
165
-
166
- // src/store/user/slices/common/action.ts
167
- const serverSettings: PartialDeep<UserSettings> = {
168
- image: serverConfig.image,
169
- // ...
170
- };
171
-
172
- // .env.example
173
- # AI_IMAGE_DEFAULT_IMAGE_NUM=4
174
- ```
175
-
@@ -1,28 +0,0 @@
1
- ---
2
- description: cursor rules writing and optimization guide
3
- globs:
4
- alwaysApply: false
5
- ---
6
- 当你编写或修改 Cursor Rule 时,请遵循以下准则:
7
-
8
- - 当你知道 rule 的文件名时,使用 `read_file` 而不是 `fetch_rules` 去读取它们,它们都在项目根目录的 `.cursor/rules/` 文件夹下
9
-
10
- - 代码示例
11
- - 示例应尽量精简,仅保留演示核心
12
- - 删除与示例无关的导入/导出语句,但保留必要的导入
13
- - 同一文件存在多个示例时,若前文已演示模块导入,后续示例可省略重复导入
14
- - 无需书写 `export`
15
- - 可省略与演示无关或重复的 props、配置对象属性、try/catch、CSS 等代码
16
- - 删除无关注释,保留有助理解的注释
17
-
18
- - 格式
19
- - 修改前请先确认原始文档语言,并保持一致
20
- - 无序列表统一使用 `-`
21
- - 列表末尾的句号是多余的
22
- - 非必要不使用加粗、行内代码等样式,Rule 主要供 LLM 阅读
23
- - 避免中英文逐句对照。若括号内容为示例而非翻译,可保留
24
-
25
- - Review
26
- - 修正 Markdown 语法问题
27
- - 纠正错别字
28
- - 指出示例与说明不一致之处
@@ -1,46 +0,0 @@
1
- ---
2
- globs: packages/database/migrations/**/*
3
- alwaysApply: false
4
- ---
5
-
6
- # Database Migrations Guide
7
-
8
- ## Step1: Generate migrations
9
-
10
- ```bash
11
- bun run db:generate
12
- ```
13
-
14
- this step will generate following files:
15
-
16
- - packages/database/migrations/0046_meaningless_file_name.sql
17
- - packages/database/migrations/0046_meaningless_file_name.sql
18
-
19
- and update the following files:
20
-
21
- - packages/database/migrations/meta/\_journal.json
22
- - packages/database/src/core/migrations.json
23
- - docs/development/database-schema.dbml
24
-
25
- ## Step2: optimize the migration sql fileName
26
-
27
- the migration sql file name is randomly generated, we need to optimize the file name to make it more readable and meaningful. For example, `0046_meaningless_file_name.sql` -> `0046_user_add_avatar_column.sql`
28
-
29
- ## Step3: Defensive Programming - Use Idempotent Clauses
30
-
31
- Always use defensive clauses to make migrations idempotent:
32
-
33
- ```sql
34
- -- ✅ Good: Idempotent operations
35
- ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "avatar" text;
36
- DROP TABLE IF EXISTS "old_table";
37
- CREATE INDEX IF NOT EXISTS "users_email_idx" ON "users" ("email");
38
- ALTER TABLE "posts" DROP COLUMN IF EXISTS "deprecated_field";
39
-
40
- -- ❌ Bad: Non-idempotent operations
41
- ALTER TABLE "users" ADD COLUMN "avatar" text;
42
- DROP TABLE "old_table";
43
- CREATE INDEX "users_email_idx" ON "users" ("email");
44
- ```
45
-
46
- **Important**: After modifying migration SQL (e.g., adding `IF NOT EXISTS` clauses), run `bun run db:generate:client` to update the hash in `packages/database/src/core/migrations.json`.