@chatbi-v/cli 1.0.5 → 1.0.7

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 (42) hide show
  1. package/dist/default/.gitignore.hbs +3 -0
  2. package/dist/default/README.md.hbs +30 -0
  3. package/dist/default/apps/main/index.html.hbs +13 -0
  4. package/dist/default/apps/main/package.json.hbs +20 -0
  5. package/dist/default/apps/main/postcss.config.cjs.hbs +6 -0
  6. package/dist/default/apps/main/src/App.tsx.hbs +162 -0
  7. package/dist/default/apps/main/src/components/NavIcon.tsx.hbs +41 -0
  8. package/dist/default/apps/main/src/hooks/usePluginLoader.ts.hbs +25 -0
  9. package/dist/default/apps/main/src/index.css.hbs +8 -0
  10. package/dist/default/apps/main/src/main.tsx.hbs +13 -0
  11. package/dist/default/apps/main/src/pages/Guide.tsx.hbs +133 -0
  12. package/dist/default/apps/main/tailwind.config.cjs.hbs +17 -0
  13. package/dist/default/apps/main/tsconfig.json.hbs +10 -0
  14. package/dist/default/apps/main/vite.config.ts.hbs +16 -0
  15. package/dist/default/package.json.hbs +33 -0
  16. package/dist/default/plugins/demo-plugin/package.json.hbs +17 -0
  17. package/dist/default/plugins/demo-plugin/src/index.tsx.hbs +44 -0
  18. package/dist/default/plugins/demo-plugin/tsconfig.json.hbs +10 -0
  19. package/dist/default/pnpm-workspace.yaml.hbs +3 -0
  20. package/dist/default/tsconfig.json.hbs +24 -0
  21. package/dist/index.js +5885 -372
  22. package/package.json +5 -3
  23. package/templates/default/.gitignore.hbs +3 -0
  24. package/templates/default/README.md.hbs +30 -0
  25. package/templates/default/apps/main/index.html.hbs +13 -0
  26. package/templates/default/apps/main/package.json.hbs +20 -0
  27. package/templates/default/apps/main/postcss.config.cjs.hbs +6 -0
  28. package/templates/default/apps/main/src/App.tsx.hbs +162 -0
  29. package/templates/default/apps/main/src/components/NavIcon.tsx.hbs +41 -0
  30. package/templates/default/apps/main/src/hooks/usePluginLoader.ts.hbs +25 -0
  31. package/templates/default/apps/main/src/index.css.hbs +8 -0
  32. package/templates/default/apps/main/src/main.tsx.hbs +13 -0
  33. package/templates/default/apps/main/src/pages/Guide.tsx.hbs +133 -0
  34. package/templates/default/apps/main/tailwind.config.cjs.hbs +17 -0
  35. package/templates/default/apps/main/tsconfig.json.hbs +10 -0
  36. package/templates/default/apps/main/vite.config.ts.hbs +16 -0
  37. package/templates/default/package.json.hbs +33 -0
  38. package/templates/default/plugins/demo-plugin/package.json.hbs +17 -0
  39. package/templates/default/plugins/demo-plugin/src/index.tsx.hbs +44 -0
  40. package/templates/default/plugins/demo-plugin/tsconfig.json.hbs +10 -0
  41. package/templates/default/pnpm-workspace.yaml.hbs +3 -0
  42. package/templates/default/tsconfig.json.hbs +24 -0
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@chatbi-v/cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Standardized CLI tooling for ChatBI Monorepo",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "chatbi-cli": "./bin/chatbi-cli.js"
8
8
  },
9
9
  "files": [
10
+ "templates",
10
11
  "dist",
11
12
  "bin"
12
13
  ],
@@ -17,17 +18,18 @@
17
18
  "cac": "^6.7.14",
18
19
  "execa": "^8.0.1",
19
20
  "fs-extra": "^11.2.0",
21
+ "handlebars": "^4.7.8",
20
22
  "picocolors": "^1.0.0",
21
23
  "tsup": "^8.5.1",
22
24
  "typescript": "^5.0.0",
23
25
  "@chatbi-v/core": "1.0.3",
24
- "@chatbi-v/plugin-system-monitor": "1.0.1",
25
26
  "@chatbi-v/plugin-system-user": "1.0.1",
27
+ "@chatbi-v/plugin-system-monitor": "1.0.1",
26
28
  "@chatbi-v/plugin-theme-manager": "1.0.2"
27
29
  },
28
30
  "devDependencies": {
29
- "@types/node": "^20.0.0",
30
31
  "@types/fs-extra": "^11.0.0",
32
+ "@types/node": "^20.0.0",
31
33
  "tsup": "^8.5.1",
32
34
  "vitest": "^1.0.0",
33
35
  "@chatbi-v/tsconfig": "1.0.2"
@@ -0,0 +1,3 @@
1
+ .chatbi/
2
+ node_modules/
3
+ dist/
@@ -0,0 +1,30 @@
1
+ # {{name}}
2
+
3
+ 基于 ChatBI-V SDK 初始化的业务插件项目。
4
+
5
+ ## 项目结构
6
+
7
+ - `apps/main`: 宿主应用,用于验证插件功能。
8
+ - `plugins/`: 业务插件源码目录。
9
+ - `.chatbi/`: 离线 SDK 资源(核心包、标准插件、CLI 工具)。
10
+
11
+ ## 快速开始
12
+
13
+ 1. 安装依赖:
14
+ ```bash
15
+ pnpm install
16
+ ```
17
+
18
+ 2. 启动开发服务器:
19
+ ```bash
20
+ pnpm dev
21
+ ```
22
+
23
+ 3. 创建新插件:
24
+ ```bash
25
+ pnpm create:plugin <plugin-name>
26
+ ```
27
+
28
+ ## 插件开发
29
+
30
+ 参考 `plugins/demo-plugin` 示例。
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>ChatBI Business Plugin Host</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@chatbi-v/main",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build"
8
+ },
9
+ "dependencies": {
10
+ "react": "^18.3.1",
11
+ "react-dom": "^18.3.1",
12
+ "react-router-dom": "^6.22.3",
13
+ "antd": "^5.20.0",
14
+ "@ant-design/icons": "^5.2.6",
15
+ "@chatbi-v/core": "link:../../.chatbi/core"
16
+ },
17
+ "devDependencies": {
18
+ "@vitejs/plugin-react": "^4.3.1"
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,162 @@
1
+ import React, { useMemo, useState } from 'react'
2
+ import { Routes, Route, Navigate, Link, useLocation, useNavigate } from 'react-router-dom'
3
+ import { usePluginLoader } from './hooks/usePluginLoader'
4
+ import { pluginManager, PluginSlot, Slot, SidebarIconSkeleton, type PluginExtension } from '@chatbi-v/core'
5
+ import { QuestionCircleOutlined, MenuFoldOutlined, MenuUnfoldOutlined, ThunderboltOutlined } from '@ant-design/icons'
6
+ import GuidePage from './pages/Guide'
7
+ import { NavIcon } from './components/NavIcon'
8
+
9
+ const App: React.FC = () => {
10
+ const { pluginsLoaded } = usePluginLoader()
11
+ const location = useLocation()
12
+ const navigate = useNavigate()
13
+ const [collapsed, setCollapsed] = useState(false)
14
+
15
+ // 收集插件路由
16
+ const routes = useMemo(() => {
17
+ return pluginsLoaded ? pluginManager.getRoutes() : []
18
+ }, [pluginsLoaded])
19
+
20
+ // 当前激活的 Tab (路径去掉前导斜杠)
21
+ const activeTab = useMemo(() => {
22
+ return location.pathname.replace(/^\//, '')
23
+ }, [location.pathname])
24
+
25
+ // 默认路由重定向逻辑
26
+ const defaultRoute = useMemo(() => {
27
+ if (routes.length > 0) {
28
+ return routes[0].path
29
+ }
30
+ return '/guide'
31
+ }, [routes])
32
+
33
+ if (!pluginsLoaded) {
34
+ return (
35
+ <div className="h-screen flex items-center justify-center bg-gray-50">
36
+ <div className="text-center">
37
+ <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto mb-4"></div>
38
+ <p className="text-gray-500">正在加载插件与内核...</p>
39
+ </div>
40
+ </div>
41
+ )
42
+ }
43
+
44
+ return (
45
+ <div className="flex h-screen flex-col overflow-hidden bg-gray-50 font-sans">
46
+ {/* Header */}
47
+ <header className="flex h-16 items-center justify-between bg-slate-900 px-6 text-white shadow-md z-10">
48
+ <div className="flex items-center gap-4">
49
+ <div className="flex items-center gap-2 group cursor-pointer" onClick={() => navigate('/')}>
50
+ <div className="w-8 h-8 rounded-lg bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20 group-hover:scale-105 transition-transform">
51
+ <ThunderboltOutlined className="text-lg text-white" />
52
+ </div>
53
+ <h2 className="m-0 text-lg font-bold tracking-tight text-white uppercase">
54
+ {{name}}
55
+ </h2>
56
+ </div>
57
+ <nav className="ml-8 flex gap-4">
58
+ <Link
59
+ to="/guide"
60
+ className={`flex items-center gap-1.5 px-3 py-1 rounded transition-colors ${
61
+ location.pathname === '/guide' ? 'bg-indigo-500/20 text-indigo-300' : 'text-gray-400 hover:text-white'
62
+ }`}
63
+ >
64
+ <QuestionCircleOutlined />
65
+ <span>开发指南</span>
66
+ </Link>
67
+ </nav>
68
+ </div>
69
+ <div className="header-actions flex items-center gap-4">
70
+ <PluginSlot slot={Slot.Header} />
71
+ </div>
72
+ </header>
73
+
74
+ <div className="flex flex-1 overflow-hidden">
75
+ {/* Sidebar */}
76
+ <aside
77
+ className={`flex flex-col border-r border-gray-200 bg-white shadow-sm transition-all duration-300 ease-in-out ${
78
+ collapsed ? 'w-16' : 'w-64'
79
+ }`}
80
+ >
81
+ <div className={`p-4 border-b border-gray-50 bg-gray-50/50 text-xs font-semibold text-gray-400 uppercase tracking-wider overflow-hidden whitespace-nowrap ${collapsed ? 'text-center px-0' : ''}`}>
82
+ {collapsed ? '···' : '插件菜单'}
83
+ </div>
84
+ <div className="flex-1 overflow-y-auto no-scrollbar py-4 px-2">
85
+ <PluginSlot
86
+ slot={Slot.Sidebar}
87
+ className="flex flex-col gap-2 w-full items-center"
88
+ skeleton={
89
+ <div className="flex flex-col gap-4 w-full items-center px-2">
90
+ {[1, 2, 3].map(i => <SidebarIconSkeleton key={i} />)}
91
+ </div>
92
+ }
93
+ renderItem={({ key, extension }: { key: string, extension: PluginExtension }) => (
94
+ <NavIcon
95
+ key={key}
96
+ icon={extension.meta?.icon}
97
+ label={extension.meta?.label}
98
+ active={
99
+ activeTab === (extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') ||
100
+ activeTab.startsWith(((extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') || '') + '/')
101
+ }
102
+ onClick={() => navigate(extension.meta?.path || '/')}
103
+ expanded={!collapsed}
104
+ />
105
+ )}
106
+ />
107
+ </div>
108
+
109
+ {/* Sidebar Footer */}
110
+ <div className="p-2 border-t border-gray-100">
111
+ <NavIcon
112
+ icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
113
+ onClick={() => setCollapsed(!collapsed)}
114
+ title={collapsed ? "展开侧边栏" : "折叠侧边栏"}
115
+ label={collapsed ? "展开" : "折叠"}
116
+ expanded={!collapsed}
117
+ />
118
+ </div>
119
+ </aside>
120
+
121
+ {/* Main Content */}
122
+ <main className="relative flex-1 overflow-y-auto bg-gray-50 p-6 scroll-smooth">
123
+ <Routes>
124
+ <Route path="/guide" element={<GuidePage />} />
125
+ {routes.map(route => (
126
+ <Route
127
+ key={route.path}
128
+ path={route.path}
129
+ element={<route.component />}
130
+ />
131
+ ))}
132
+ <Route path="/" element={<Navigate to={defaultRoute} replace />} />
133
+ <Route path="*" element={
134
+ <div className="mt-24 text-center">
135
+ <h3 className="text-2xl font-bold text-gray-800">404 Not Found</h3>
136
+ <p className="mt-2 text-gray-500">请求的页面不存在或插件未加载。</p>
137
+ <Link to="/guide" className="mt-6 inline-block text-indigo-500 hover:text-indigo-600">
138
+ 返回开发指南
139
+ </Link>
140
+ </div>
141
+ } />
142
+ </Routes>
143
+ <div className="mt-8">
144
+ <PluginSlot slot={Slot.Custom} />
145
+ </div>
146
+ </main>
147
+ </div>
148
+
149
+ {/* Footer */}
150
+ <footer className="h-10 flex items-center px-4 bg-white border-t border-gray-200 text-xs text-gray-400 shrink-0">
151
+ <div className="flex-1 flex items-center">
152
+ <PluginSlot slot={Slot.StatusBar} />
153
+ </div>
154
+ <div>
155
+ SDK Version: 1.0.0
156
+ </div>
157
+ </footer>
158
+ </div>
159
+ )
160
+ }
161
+
162
+ export default App
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+
3
+ export const NavIcon = React.memo(({
4
+ icon,
5
+ active,
6
+ onClick,
7
+ title,
8
+ label,
9
+ expanded,
10
+ }: {
11
+ icon: React.ReactNode;
12
+ active?: boolean;
13
+ onClick?: () => void;
14
+ title?: string;
15
+ label?: string;
16
+ expanded?: boolean;
17
+ }) => (
18
+ <div
19
+ onClick={onClick}
20
+ title={title}
21
+ className={`flex items-center cursor-pointer transition-all duration-300 relative group
22
+ ${expanded ? 'w-full' : 'w-12'} px-3 h-11 rounded-xl
23
+ ${
24
+ active
25
+ ? 'bg-indigo-500/15 text-indigo-600 font-semibold shadow-sm ring-1 ring-indigo-500/20'
26
+ : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900 hover:scale-105 active:scale-95'
27
+ }`}
28
+ >
29
+ <div className="w-6 h-6 flex items-center justify-center shrink-0">
30
+ <div className={`text-xl transition-transform duration-300 ${!expanded && active ? 'scale-110' : ''}`}>{icon}</div>
31
+ </div>
32
+
33
+ <div className={`overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out ${
34
+ expanded ? 'w-auto opacity-100 ml-3' : 'w-0 opacity-0 ml-0'
35
+ }`}>
36
+ <span className="text-sm block">
37
+ {label}
38
+ </span>
39
+ </div>
40
+ </div>
41
+ ));
@@ -0,0 +1,25 @@
1
+ import { usePluginLoader as useCoreLoader } from '@chatbi-v/core'
2
+ import { useMemo } from 'react'
3
+
4
+ // 离线插件注册表
5
+ const offlineRegistry = {
6
+ "theme-manager": () => import("@chatbi-v/plugin-theme-manager"),
7
+ "system-user": () => import("@chatbi-v/plugin-system-user"),
8
+ "system-monitor": () => import("@chatbi-v/plugin-system-monitor"),
9
+ "demo-plugin": () => import("@chatbi-v/plugin-demo-plugin")
10
+ }
11
+
12
+ export const usePluginLoader = () => {
13
+ const options = useMemo(() => ({
14
+ pluginConfigs: {
15
+ 'theme-manager': { enabled: true },
16
+ 'system-user': { enabled: true },
17
+ 'system-monitor': { enabled: true },
18
+ 'demo-plugin': { enabled: true }
19
+ },
20
+ registry: offlineRegistry,
21
+ sharedContext: { api: {} }
22
+ }), [])
23
+
24
+ return useCoreLoader(options)
25
+ }
@@ -0,0 +1,8 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ --layout-sidebar-width: 260px;
7
+ --layout-gap: 16px;
8
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import { HashRouter } from 'react-router-dom'
4
+ import App from './App'
5
+ import './index.css'
6
+
7
+ ReactDOM.createRoot(document.getElementById('root')!).render(
8
+ <React.StrictMode>
9
+ <HashRouter>
10
+ <App />
11
+ </HashRouter>
12
+ </React.StrictMode>,
13
+ )
@@ -0,0 +1,133 @@
1
+ import React from 'react';
2
+ import { Typography, Card, Space, Divider, List, Tag } from 'antd';
3
+ import {
4
+ FolderOpenOutlined,
5
+ RocketOutlined,
6
+ BuildOutlined,
7
+ CodeOutlined,
8
+ BlockOutlined,
9
+ SettingOutlined
10
+ } from '@ant-design/icons';
11
+
12
+ const { Title, Paragraph, Text } = Typography;
13
+
14
+ const GuidePage: React.FC = () => {
15
+ return (
16
+ <div className="max-w-4xl mx-auto py-8 px-4">
17
+ <Typography>
18
+ <Title level={2} className="flex items-center gap-2">
19
+ <RocketOutlined className="text-indigo-500" />
20
+ 欢迎使用 {{name}} 开发容器
21
+ </Title>
22
+ <Paragraph className="text-gray-500 text-lg">
23
+ 这是一个基于 ChatBI-V SDK 构建的业务插件开发环境。你可以通过此容器快速开发、调试并预览你的插件。
24
+ </Paragraph>
25
+ </Typography>
26
+
27
+ <Divider />
28
+
29
+ <Space direction="vertical" size="large" className="w-full">
30
+ {/* 项目目录介绍 */}
31
+ <Card
32
+ title={<span className="flex items-center gap-2"><FolderOpenOutlined /> 项目目录介绍</span>}
33
+ variant="borderless"
34
+ className="shadow-sm"
35
+ >
36
+ <List
37
+ itemLayout="horizontal"
38
+ dataSource={[
39
+ {
40
+ title: 'apps/main',
41
+ description: '宿主应用框架,负责加载插件、提供布局和基础能力。',
42
+ icon: <BlockOutlined className="text-blue-500" />
43
+ },
44
+ {
45
+ title: 'plugins/',
46
+ description: '业务插件源码目录,你开发的所有插件都应放置在此目录下。',
47
+ icon: <CodeOutlined className="text-green-500" />
48
+ },
49
+ {
50
+ title: '.chatbi/',
51
+ description: '离线 SDK 资源,包含核心库 (@chatbi-v/core) 和内置标准插件。',
52
+ icon: <SettingOutlined className="text-orange-500" />
53
+ },
54
+ {
55
+ title: 'scripts/',
56
+ description: '辅助开发脚本,如快速创建插件脚本。',
57
+ icon: <BuildOutlined className="text-purple-500" />
58
+ }
59
+ ]}
60
+ renderItem={(item) => (
61
+ <List.Item>
62
+ <List.Item.Meta
63
+ avatar={item.icon}
64
+ title={<Text strong>{item.title}</Text>}
65
+ description={item.description}
66
+ />
67
+ </List.Item>
68
+ )}
69
+ />
70
+ </Card>
71
+
72
+ {/* 开发指南 */}
73
+ <Card
74
+ title={<span className="flex items-center gap-2"><BuildOutlined /> 开发指南</span>}
75
+ variant="borderless"
76
+ className="shadow-sm"
77
+ >
78
+ <div className="space-y-4">
79
+ <div>
80
+ <Text strong className="block mb-2">1. 安装依赖</Text>
81
+ <Tag color="default" className="font-mono px-2 py-1">pnpm install</Tag>
82
+ </div>
83
+ <div>
84
+ <Text strong className="block mb-2">2. 启动开发环境</Text>
85
+ <Tag color="blue" className="font-mono px-2 py-1">pnpm dev</Tag>
86
+ <Paragraph className="mt-2 text-gray-500 text-sm">
87
+ 该命令会同时启动宿主应用和监听插件变化。
88
+ </Paragraph>
89
+ </div>
90
+ <div>
91
+ <Text strong className="block mb-2">3. 构建发布</Text>
92
+ <Tag color="green" className="font-mono px-2 py-1">pnpm build</Tag>
93
+ <Paragraph className="mt-2 text-gray-500 text-sm">
94
+ 生成生产环境可用的静态资源。
95
+ </Paragraph>
96
+ </div>
97
+ </div>
98
+ </Card>
99
+
100
+ {/* 插件开发指南 */}
101
+ <Card
102
+ title={<span className="flex items-center gap-2"><CodeOutlined /> 插件开发指南</span>}
103
+ variant="borderless"
104
+ className="shadow-sm"
105
+ >
106
+ <Typography>
107
+ <Paragraph>
108
+ 要创建一个新的业务插件,请运行:
109
+ </Paragraph>
110
+ <Tag color="magenta" className="font-mono px-2 py-1 mb-4">pnpm create:plugin [plugin-name]</Tag>
111
+
112
+ <Title level={5}>插件核心结构:</Title>
113
+ <Paragraph>
114
+ 每个插件都需要继承自 <Text code>Plugin</Text> 类并导出。关键属性包括:
115
+ </Paragraph>
116
+ <ul className="list-disc pl-5 space-y-2 text-gray-600">
117
+ <li><Text strong>id</Text>: 插件唯一标识。</li>
118
+ <li><Text strong>metadata.routes</Text>: 定义插件自带的页面路由。</li>
119
+ <li><Text strong>metadata.extensions</Text>: 通过插槽 (Slot) 扩展宿主应用的 UI。</li>
120
+ <li><Text strong>onLoad</Text>: 插件加载时的初始化逻辑。</li>
121
+ </ul>
122
+ </Typography>
123
+ </Card>
124
+ </Space>
125
+
126
+ <div className="mt-12 text-center text-gray-400 text-sm">
127
+ © 2025 ChatBI-V System. All rights reserved.
128
+ </div>
129
+ </div>
130
+ );
131
+ };
132
+
133
+ export default GuidePage;
@@ -0,0 +1,17 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ "./index.html",
5
+ "./src/**/*.{js,ts,jsx,tsx}",
6
+ "../../plugins/*/src/**/*.{js,ts,jsx,tsx}",
7
+ "../../.chatbi/plugins/*/dist/*.{js,mjs}"
8
+ ],
9
+ theme: {
10
+ extend: {
11
+ colors: {
12
+ primary: '#6366f1',
13
+ }
14
+ },
15
+ },
16
+ plugins: [],
17
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ },
9
+ "include": ["src"]
10
+ }
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import path from 'path'
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ resolve: {
8
+ alias: {
9
+ '@chatbi-v/core': path.resolve(__dirname, '../../.chatbi/core'),
10
+ '@chatbi-v/plugin-theme-manager': path.resolve(__dirname, '../../.chatbi/plugins/theme-manager/dist/index.mjs'),
11
+ '@chatbi-v/plugin-system-user': path.resolve(__dirname, '../../.chatbi/plugins/system-user/dist/index.mjs'),
12
+ '@chatbi-v/plugin-system-monitor': path.resolve(__dirname, '../../.chatbi/plugins/system-monitor/dist/index.mjs'),
13
+ '@chatbi-v/plugin-demo-plugin': path.resolve(__dirname, '../../plugins/demo-plugin/src/index.tsx'),
14
+ }
15
+ }
16
+ })
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "pnpm --filter @chatbi-v/main dev",
8
+ "build": "pnpm -r build",
9
+ "create:plugin": "node scripts/create-plugin.js"
10
+ },
11
+ "workspaces": [
12
+ "apps/*",
13
+ "plugins/*"
14
+ ],
15
+ "dependencies": {
16
+ "antd": "^5.29.3",
17
+ "axios": "^1.13.2",
18
+ "clsx": "^2.1.1",
19
+ "echarts-for-react": "^3.0.5",
20
+ "reactflow": "^11.11.4"
21
+ },
22
+ "devDependencies": {
23
+ "typescript": "^5.0.0",
24
+ "@chatbi-v/cli": "link:./.chatbi/cli",
25
+ "@ant-design/icons": "^5.6.1",
26
+ "vite": "^5.4.0",
27
+ "@vitejs/plugin-react": "^4.3.1",
28
+ "tailwindcss": "^3.4.0",
29
+ "postcss": "^8.4.0",
30
+ "autoprefixer": "^10.4.0",
31
+ "pnpm": ">=9.0.0"
32
+ }
33
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@chatbi-v/plugin-demo-plugin",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "plugin": true,
6
+ "main": "src/index.tsx",
7
+ "module": "src/index.tsx",
8
+ "exports": {
9
+ ".": "./src/index.tsx"
10
+ },
11
+ "scripts": {
12
+ "build": "chatbi-cli build"
13
+ },
14
+ "dependencies": {
15
+ "@chatbi-v/core": "link:../../.chatbi/core"
16
+ }
17
+ }
@@ -0,0 +1,44 @@
1
+ import React from 'react'
2
+ import { Plugin, PluginContext, Slot } from '@chatbi-v/core'
3
+ import { MessageOutlined } from '@ant-design/icons'
4
+
5
+ export class DemoPlugin implements Plugin {
6
+ id = 'demo-plugin'
7
+ metadata = {
8
+ id: 'demo-plugin',
9
+ name: 'Demo Business Plugin',
10
+ version: '1.0.0',
11
+ type: 'business' as const,
12
+ routes: [
13
+ {
14
+ path: '/demo',
15
+ component: () => <div style=\{{ padding: '20px', background: '#f5f5f5', borderRadius: '8px' }}>
16
+ <h3>Hello from Demo Plugin!</h3>
17
+ <p>This is a business plugin generated by ChatBI CLI.</p>
18
+ </div>,
19
+ meta: {
20
+ title: '演示',
21
+ icon: 'MessageOutlined'
22
+ }
23
+ }
24
+ ],
25
+ extensions: [
26
+ {
27
+ slot: Slot.Sidebar,
28
+ component: () => null,
29
+ order: 10,
30
+ meta: {
31
+ title: '演示',
32
+ icon: <MessageOutlined />,
33
+ path: '/demo'
34
+ }
35
+ }
36
+ ]
37
+ }
38
+
39
+ onLoad(context: PluginContext) {
40
+ context.logger.info('Demo Plugin Loaded!')
41
+ }
42
+ }
43
+
44
+ export default DemoPlugin
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ },
9
+ "include": ["src"]
10
+ }
@@ -0,0 +1,3 @@
1
+ packages:
2
+ - 'apps/*'
3
+ - 'plugins/*'