Files
lobehub/vite.config.ts
Innei 4438b559e6 feat: add slash action tags, topic reference tool, and command bus system (#12860)
*  feat: add slash action tags in chat input

Made-with: Cursor

*  feat: enhance editor with new slash actions and localization updates

- Added new slash actions: change tone, condense, expand, polish, rewrite, summarize, and translate.
- Updated localization files for English and Chinese to include new action tags and slash commands.
- Removed deprecated useSlashItems component and integrated its functionality directly into InputEditor.

Signed-off-by: Innei <tukon479@gmail.com>

*  feat: add slash placement configuration to chat input components

- Introduced `slashPlacement` prop to `ChatInputProvider`, `StoreUpdater`, and `InputEditor` for customizable slash menu positioning.
- Updated initial state to include `slashPlacement` with default value 'top'.
- Adjusted `ChatInput` and `InputArea` components to utilize the new `slashPlacement` prop.

This enhancement allows for better control over the user interface in chat input interactions.

Signed-off-by: Innei <tukon479@gmail.com>

*  feat: implement command bus for slash action tags processing

Add command bus system to parse and execute slash commands (compact context,
new topic). Refactor action tag categories from ai/prompt to command/skill.
Add useEnabledSkills hook for dynamic skill registration.

* feat: compress command

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: compress

Signed-off-by: Innei <tukon479@gmail.com>

* fix: skill inject

*  feat: slash action tags with context engine integration

Made-with: Cursor

*  feat: add topic reference builtin tool and server runtime

Made-with: Cursor

*  feat: add topic mention items and update ReferTopic integration

Made-with: Cursor

* 🐛 fix: preserve editorData through assistant-group edit flow and update RichTextMessage reactively

- EditState now forwards editorData from EditorModal to modifyMessageContent
- modifyMessageContent accepts and passes editorData to updateMessageContent
- RichTextMessage uses useEditor + effect to update document on content change instead of key-based remount
- Refactored RichTextMessage plugins to use shared createChatInputRichPlugins()

*  feat(context-engine): add metadata types and update processors/providers

Made-with: Cursor

*  feat(chat-input): add slash action tags and restore failed input state

* 🔧 chore: update package dependencies and enhance Vite configuration

- Changed @lobehub/ui dependency to a specific package URL.
- Added multiple SPA entry points and layout files to the Vite warmup configuration.
- Removed unused monorepo packages from sharedOptimizeDeps and added various dayjs locales for better localization support.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update @lobehub/ui dependency to version 5.4.0 in package.json

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix: correct SkillsApiName.runSkill to activateSkill and update trimmed content assertions

* 🐛 fix: resolve type errors in context-engine tests and InputEditor slashPlacement

* 🐛 fix: update runSkill to activateSkill in conversationLifecycle test

* 🐛 fix: avoid regex backtracking in placeholder parser

*  feat(localization): add action tags and tooltips for slash commands across multiple languages

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix: preserve file attachments when /newTopic has no text content

* cleanup

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-13 22:17:36 +08:00

165 lines
5.5 KiB
TypeScript

import { resolve } from 'node:path';
import type { PluginOption, ViteDevServer } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import { viteEnvRestartKeys } from './plugins/vite/envRestartKeys';
import {
sharedOptimizeDeps,
sharedRendererDefine,
sharedRendererPlugins,
sharedRollupOutput,
} from './plugins/vite/sharedRendererConfig';
import { vercelSkewProtection } from './plugins/vite/vercelSkewProtection';
const isMobile = process.env.MOBILE === 'true';
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development';
Object.assign(process.env, loadEnv(mode, process.cwd(), ''));
const isDev = process.env.NODE_ENV !== 'production';
const platform = isMobile ? 'mobile' : 'web';
export default defineConfig({
base: isDev ? '/' : process.env.VITE_CDN_BASE || '/spa/',
build: {
outDir: isMobile ? 'dist/mobile' : 'dist/desktop',
rollupOptions: {
input: resolve(__dirname, isMobile ? 'index.mobile.html' : 'index.html'),
output: sharedRollupOutput,
},
},
define: sharedRendererDefine({ isMobile, isElectron: false }),
optimizeDeps: sharedOptimizeDeps,
plugins: [
vercelSkewProtection(),
viteEnvRestartKeys(['APP_URL']),
...sharedRendererPlugins({ platform }),
isDev && {
name: 'lobe-dev-proxy-print',
configureServer(server: ViteDevServer) {
const ONLINE_HOST = 'https://app.lobehub.com';
const c = {
green: (s: string) => `\x1B[32m${s}\x1B[0m`,
bold: (s: string) => `\x1B[1m${s}\x1B[0m`,
cyan: (s: string) => `\x1B[36m${s}\x1B[0m`,
};
const { info } = server.config.logger;
return () => {
server.printUrls = () => {
const urls = server.resolvedUrls;
if (!urls?.local?.[0]) return;
const localHost = urls.local[0].replace(/\/$/, '');
const proxyUrl = `${ONLINE_HOST}/_dangerous_local_dev_proxy?debug-host=${encodeURIComponent(localHost)}`;
const colorUrl = (url: string) =>
c.cyan(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
info(` ${c.green('➜')} ${c.bold('Debug Proxy')}: ${colorUrl(proxyUrl)}`);
};
};
},
},
VitePWA({
injectRegister: null,
manifest: false,
registerType: 'prompt',
workbox: {
globPatterns: ['**/*.{js,css,html,woff2}'],
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
runtimeCaching: [
{
handler: 'StaleWhileRevalidate',
options: { cacheName: 'google-fonts-stylesheets' },
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
},
{
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-webfonts',
expiration: { maxAgeSeconds: 60 * 60 * 24 * 365, maxEntries: 30 },
},
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
},
{
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'image-assets',
expiration: { maxAgeSeconds: 60 * 60 * 24 * 30, maxEntries: 100 },
},
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico|avif)$/i,
},
{
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: { maxAgeSeconds: 60 * 5, maxEntries: 50 },
},
urlPattern: /\/(api|trpc)\/.*/i,
},
],
},
}),
].filter(Boolean) as PluginOption[],
server: {
cors: true,
port: 9876,
host: true,
proxy: {
'/api': 'http://localhost:3010',
'/oidc': 'http://localhost:3010',
'/trpc': 'http://localhost:3010',
'/webapi': 'http://localhost:3010',
},
warmup: {
clientFiles: [
// src/ business code
'./src/initialize.ts',
'./src/spa/**/*.tsx',
'./src/business/**/*.{ts,tsx}',
'./src/components/**/*.{ts,tsx}',
'./src/config/**/*.ts',
'./src/const/**/*.ts',
'./src/envs/**/*.ts',
'./src/features/**/*.{ts,tsx}',
'./src/helpers/**/*.ts',
'./src/hooks/**/*.{ts,tsx}',
'./src/layout/**/*.{ts,tsx}',
'./src/libs/**/*.{ts,tsx}',
'./src/locales/**/*.ts',
'./src/routes/**/*.{ts,tsx}',
'./src/services/**/*.ts',
'./src/store/**/*.{ts,tsx}',
'./src/styles/**/*.ts',
'./src/utils/**/*.{ts,tsx}',
// monorepo packages
'./packages/types/src/**/*.ts',
'./packages/const/src/**/*.ts',
'./packages/utils/src/**/*.ts',
'./packages/context-engine/src/**/*.ts',
'./packages/prompts/src/**/*.ts',
'./packages/model-bank/src/**/*.ts',
'./packages/model-runtime/src/**/*.ts',
'./packages/agent-runtime/src/**/*.ts',
'./packages/conversation-flow/src/**/*.ts',
'./packages/electron-client-ipc/src/**/*.ts',
'./packages/builtin-agents/src/**/*.ts',
'./packages/builtin-skills/src/**/*.ts',
'./packages/builtin-tool-*/src/**/*.ts',
'./packages/builtin-tools/src/**/*.ts',
'./packages/business/*/src/**/*.ts',
'./packages/config/src/**/*.ts',
'./packages/edge-config/src/**/*.ts',
'./packages/editor-runtime/src/**/*.ts',
'./packages/fetch-sse/src/**/*.ts',
'./packages/desktop-bridge/src/**/*.ts',
'./packages/python-interpreter/src/**/*.ts',
'./packages/agent-manager-runtime/src/**/*.ts',
],
},
},
});