@panda-agent/panda-cli 0.1.12

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.
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # 智能化办公 - Dify 独立前端
2
+
3
+ 基于 Next.js 15 和 Dify 后端 API 的独立前端应用,提供类似 NotebookLM 的三栏布局界面。
4
+
5
+ ## 项目结构
6
+
7
+ ```
8
+ src/
9
+ ├── app/ # Next.js App Router
10
+ │ ├── (auth)/ # 认证相关页面
11
+ │ │ ├── signin/ # 登录页
12
+ │ │ └── signup/ # 注册页
13
+ │ ├── (main)/ # 主应用布局(三栏)
14
+ │ │ ├── layout.tsx # 三栏布局
15
+ │ │ ├── page.tsx # 首页(聊天)
16
+ │ │ ├── conversations/ # 会话管理
17
+ │ │ ├── datasets/ # 知识库管理
18
+ │ │ └── notebooks/ # 笔记管理
19
+ │ ├── layout.tsx # 根布局
20
+ │ ├── providers.tsx # React Query Provider
21
+ │ └── globals.css # 全局样式
22
+ ├── components/
23
+ │ ├── ui/ # 基础 UI 组件
24
+ │ │ ├── button.tsx
25
+ │ │ └── input.tsx
26
+ │ ├── layout/ # 布局组件
27
+ │ │ ├── top-nav.tsx # 顶部导航
28
+ │ │ ├── left-sidebar.tsx # 左栏(来源)
29
+ │ │ ├── right-sidebar.tsx# 右栏(Studio)
30
+ │ │ └── status-bar.tsx # 底部状态栏
31
+ │ ├── chat/ # 聊天组件
32
+ │ │ ├── chat-area.tsx
33
+ │ │ ├── message-list.tsx
34
+ │ │ ├── message-item.tsx
35
+ │ │ └── chat-input.tsx
36
+ │ ├── sources/ # 来源管理组件(待实现)
37
+ │ └── studio/ # Studio 工具组件(待实现)
38
+ ├── services/
39
+ │ └── dify-client.ts # Dify API 客户端
40
+ ├── stores/
41
+ │ ├── auth-store.ts # 认证状态 (Zustand)
42
+ │ └── chat-store.ts # 聊天状态 (Zustand)
43
+ ├── hooks/
44
+ │ └── use-chat.ts # 聊天 Hook
45
+ ├── lib/
46
+ │ └── utils.ts # 工具函数
47
+ └── types/
48
+ └── index.ts # TypeScript 类型定义
49
+ ```
50
+
51
+ ## 已完成功能
52
+
53
+ ### 阶段 1: 基础架构 ✅
54
+ - [x] Next.js 15 项目初始化
55
+ - [x] Tailwind CSS 4 + 暗色主题支持
56
+ - [x] Zustand 状态管理
57
+ - [x] TanStack Query 数据缓存
58
+ - [x] TypeScript 类型定义
59
+ - [x] Dify API 客户端封装
60
+
61
+ ### 阶段 2: 认证系统
62
+ - [x] 登录页面
63
+ - [ ] 注册页面
64
+ - [ ] 密码找回
65
+ - [ ] OAuth 登录
66
+
67
+ ### 阶段 3: 三栏布局 ✅
68
+ - [x] 主布局(响应式)
69
+ - [x] 顶部导航栏
70
+ - [x] 左侧边栏(来源管理)
71
+ - [x] 右侧边栏(Studio 工具)
72
+ - [x] 底部状态栏
73
+
74
+ ### 阶段 4: 聊天功能 🟡
75
+ - [x] 聊天区域组件
76
+ - [x] 消息列表
77
+ - [x] 消息项(支持引用)
78
+ - [x] 聊天输入框(支持文件拖放)
79
+ - [x] 流式响应处理
80
+ - [ ] 会话管理(创建/删除/重命名)
81
+ - [ ] 会话历史加载
82
+
83
+ ## 待实现功能
84
+
85
+ ### 阶段 5: 来源管理
86
+ - [ ] 知识库列表和选择
87
+ - [ ] 文件上传组件
88
+ - [ ] 网站链接添加
89
+ - [ ] 来源状态监控
90
+
91
+ ### 阶段 6: 笔记功能
92
+ - [ ] 笔记数据库设计
93
+ - [ ] 笔记 API 服务
94
+ - [ ] 笔记编辑器
95
+ - [ ] 笔记与会话关联
96
+
97
+ ### 阶段 7: Studio 工具
98
+ - [ ] 音频概览(TTS)
99
+ - [ ] 报告生成
100
+ - [ ] 思维导图
101
+ - [ ] 闪卡/测验
102
+
103
+ ### 阶段 8: 优化
104
+ - [ ] 性能优化(虚拟列表)
105
+ - [ ] 错误边界
106
+ - [ ] 加载状态优化
107
+ - [ ] 端到端测试
108
+
109
+ ## 开发指南
110
+
111
+ ### 环境配置
112
+
113
+ 1. 复制 `.env.local.example` 到 `.env.local`
114
+ 2. 配置 Dify 后端 API 地址:
115
+ ```bash
116
+ NEXT_PUBLIC_DIFY_API_URL=http://localhost:5001
117
+ ```
118
+
119
+ ### 启动开发服务器
120
+
121
+ ```bash
122
+ npm run dev
123
+ ```
124
+
125
+ 访问 http://localhost:3000
126
+
127
+ ### 构建生产版本
128
+ ```bash
129
+ npm run build
130
+ npm start
131
+ ```
132
+
133
+ ## API 集成
134
+
135
+ ### Dify API 端点
136
+
137
+ - **认证**: `/console/api/login`, `/console/api/register`
138
+ - **聊天**: `/v1/chat-messages` (支持流式)
139
+ - **会话**: `/v1/conversations`
140
+ - **知识库**: `/console/api/datasets`
141
+
142
+ ### 添加新的 API 调用
143
+
144
+ 在 `src/services/dify-client.ts` 中添加新方法:
145
+
146
+ ```typescript
147
+ async myNewMethod(params: MyParams): Promise<ApiResponse<MyResult>> {
148
+ return this.fetch('/endpoint', {
149
+ method: 'POST',
150
+ body: JSON.stringify(params),
151
+ })
152
+ }
153
+ ```
154
+
155
+ ## 状态管理
156
+
157
+ ### Auth Store
158
+
159
+ ```typescript
160
+ import { useAuthStore } from '@/stores/auth-store'
161
+
162
+ const { user, login, logout } = useAuthStore()
163
+ ```
164
+
165
+ ### Chat Store
166
+
167
+ ```typescript
168
+ import { useChatStore } from '@/stores/chat-store'
169
+
170
+ const { messages, addMessage, updateMessage } = useChatStore()
171
+ ```
172
+
173
+ ## 技术栈
174
+
175
+ - **框架**: Next.js 15 (App Router)
176
+ - **语言**: TypeScript 5
177
+ - **样式**: Tailwind CSS 4
178
+ - **状态管理**: Zustand 5
179
+ - **数据获取**: TanStack Query 5
180
+ - **图标**: Lucide React
181
+ - **UI 组件**: 自研(基于 Shadcn/ui 设计)
182
+
183
+ ## 下一步
184
+
185
+ 1. **完成认证流程** - 注册、密码找回
186
+ 2. **实现会话管理** - 加载历史会话、创建新会话
187
+ 3. **集成知识库** - 来源选择、文件上传
188
+ 4. **完善 Studio 工具** - 音频概览、报告生成
189
+
190
+ ## License
191
+
192
+ MIT
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 全局/本地安装后的入口:工作目录始终为调用方 shell 的 cwd(默认 spawn 即 process.cwd())。
4
+ * 先 dedupe(仅 vscode monorepo 时删本包内 react)再启动 bundle。
5
+ */
6
+ import { spawnSync } from 'node:child_process';
7
+ import { existsSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+
11
+ const here = dirname(fileURLToPath(import.meta.url));
12
+ const pkgRoot = join(here, '..');
13
+ const dedupe = join(pkgRoot, 'scripts', 'dedupe-react-for-cli.mjs');
14
+ const bundle = join(pkgRoot, 'dist', 'panda-cli-ink.bundle.mjs');
15
+
16
+ if (!existsSync(bundle)) {
17
+ console.error(
18
+ '[pandacli] 缺少 dist/panda-cli-ink.bundle.mjs。请在包源码目录执行: npm run vendor:panda-ink && npm run build,或重新安装/打包容器。',
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ const dedupeResult = spawnSync(process.execPath, [dedupe], {
24
+ stdio: 'inherit',
25
+ cwd: pkgRoot,
26
+ env: process.env,
27
+ });
28
+ if (dedupeResult.status !== 0) {
29
+ process.exit(dedupeResult.status === null ? 1 : dedupeResult.status);
30
+ }
31
+
32
+ const run = spawnSync(
33
+ process.execPath,
34
+ ['--max-old-space-size=16384', bundle, ...process.argv.slice(2)],
35
+ {
36
+ stdio: 'inherit',
37
+ cwd: process.cwd(),
38
+ env: process.env,
39
+ },
40
+ );
41
+ process.exit(run.status ?? (run.signal ? 1 : 0));