refactor: improve codebase structure and Univer integration

- Add AGENTS.md knowledge base with project documentation
- Move UserPreferences model to separate models.py file
- Extract API_KEY to environment variable for security
- Enhance Univer Editor with PPTX support and improved UI
- Improve file system handling with binary file detection
- Add HF_ENDPOINT mirror for better China connectivity
- Clean up unused imports and code structure
This commit is contained in:
2026-04-11 09:24:14 +08:00
parent 2fdc996af9
commit d8b7832b14
18 changed files with 901 additions and 544 deletions
+42
View File
@@ -0,0 +1,42 @@
# Plugins 模块指南
## OVERVIEW
Milkdown/ProseMirror 插件,AI 补全核心逻辑。
## STRUCTURE
- copilotPlugin.ts - ProseMirror Mark 系统、ghost text、防抖请求
- docBlockPlugin.ts - 文档块插件
- mermaidPlugin.ts - Mermaid 图表渲染
- index.ts - 插件导出
- types.ts - 类型定义
## WHERE TO LOOK
| 任务 | 文件 | 说明 |
|------|------|------|
| AI 补全核心 | copilotPlugin.ts | ProseMirror Mark、ghost text |
| 文档块处理 | docBlockPlugin.ts | 文档块解析与渲染 |
| Mermaid 图表 | mermaidPlugin.ts | 图表渲染集成 |
| 插件导出 | index.ts | 统一导出入口 |
| 类型定义 | types.ts | 公共类型 |
## 关键函数
- scheduleFetch - 防抖触发补全请求
- insertGhostText - 插入 ghost text
- acceptSuggestion - Tab 接受建议
- rejectSuggestion - Esc 取消建议
## CONVENTIONS
- TypeScript 2 空格缩进
- 函数:camelCase
- 接口/类型:PascalCase
## ANTI-PATTERNS
- 空 catch 块
- 类型错误使用 as any
- 硬编码超时值
## 注意事项
- 防抖时间:1000ms(可配置)
- 文档大小限制:32KB 自动禁用
- Tab/Esc 快捷键交互