feat: Agent 思考模式前端可控、子代理全链路持久化、权限系统、工具 ID 追踪体系、前端面板与文档架构重构
- AgentConfig/LlmClient 新增 enable_thinking 参数,前端 SSE 请求传递 thinking 开关,仅千问/DashScope 时启用 - 完善权限系统,支持细粒度的权限控制和用户权限申请 - delegate_research 工具重命名为 subagent,SubAgentTool/SubAgentRunner 重构 - 子代理消息(system/user/assistant/tool)持久化到 agent_messages 表,带 agent_name 标识 - 子代理活动日志(工具调用列表+思考摘要)注入返回结果,Hooks 获得正确 session_id 和 subagent_name - LLM 工具调用 ID 回退生成 UUID(llm.rs),ToolCall/ToolResult SSE 事件增加 id/tool_call_id 双字段 - ToolContext 扩展 session_id/sse_tx/enable_thinking 字段,executor 统一注入而非构造函数传参 - agent_messages 新增 metadata+raw_json 列,agent_sessions 暴露 summary 字段 - 删除文件级 transcript 快照(compact.rs),改为依赖 DB 持久化 - ResearchAgentPanel 重写:TimelineItem 类型替代 StreamStep,支持会话历史回放 - 新增 AgentMetricsPanel/AskUserQuestionCard/AuditLogViewer 三个前端组件,types.ts 完整类型定义 - docs/architecture/ 分层重组:概览/核心模块/核心工作流 + agent/ 子目录 11 篇专题文档 - docs/api.md 补充 RAG/Target/Agent 接口,docs/development.md 新建开发指南 - .env.example 完全重写,补充 FALLBACK_MODEL 等变量说明
This commit is contained in:
+7
-45
@@ -1,54 +1,16 @@
|
||||
# AstroResearch Contributing Guide / 参与贡献
|
||||
|
||||
我们欢迎社区共同参与 AstroResearch 的开发与优化。以下是关于本地开发调试、代码规范和测试的说明。
|
||||
我们欢迎社区共同参与 AstroResearch 的开发与优化。
|
||||
|
||||
环境搭建和项目结构详见 **[开发指南](development.md)**。
|
||||
|
||||
---
|
||||
|
||||
## 1. 开发者本地环境搭建 (Developer Setup)
|
||||
|
||||
### 后端开发环境 (Rust)
|
||||
1. 准备 Rust 工具链 (Edition 2021)。
|
||||
2. 安装 SQLx CLI(可选,用于生成迁移文件):
|
||||
```bash
|
||||
cargo install sqlx-cli --no-default-features --features sqlite
|
||||
```
|
||||
3. 启动开发模式下的 Rust 服务:
|
||||
```bash
|
||||
cargo run
|
||||
```
|
||||
|
||||
### 前端开发环境 (React + TypeScript)
|
||||
1. 进入 `dashboard` 目录,安装依赖:
|
||||
```bash
|
||||
cd dashboard
|
||||
npm install
|
||||
```
|
||||
2. 启动开发服务器(支持 HMR 热更新及 API 请求代理转发):
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
## 1. 项目结构约定 (Project Structure Conventions)
|
||||
|
||||
---
|
||||
|
||||
## 2. 项目结构约定 (Project Structure Conventions)
|
||||
|
||||
### 后端模块化架构
|
||||
|
||||
后端代码已从单文件架构重构为模块化架构:
|
||||
|
||||
- **API 层** (`src/api/`):按职责拆分为 `papers.rs`(文献相关)、`notes.rs`(笔记相关)、`sync.rs`(同步相关)、`helpers.rs`(共享工具),通过 `mod.rs` 统一暴露 `AppState`、`StandardPaper` 和向后兼容的 `handlers` 命名空间。
|
||||
- **服务层** (`src/services/`):批量同步引擎从单文件 `batch_sync.rs` 拆分为 `batch/mod.rs` + `meta.rs` + `asset.rs`,同时通过 `pub mod batch_sync` 保持路径兼容。
|
||||
- **独立工具** (`src/bin/`):`health_check.rs` 作为独立二进制程序,可直接运行。
|
||||
|
||||
### 前端组件化架构
|
||||
|
||||
- **可复用组件** (`components/`):`CustomSelect` 替代所有原生 `<select>`,保持视觉一致性。
|
||||
- **功能模块** (`features/`):按功能域划分(search、library、reader、citation、sync、settings)。
|
||||
- **类型定义** (`types.ts`):集中管理所有接口类型,与后端 `StandardPaper` 结构体保持同步。
|
||||
|
||||
---
|
||||
|
||||
## 3. 编码规范 (Coding Style Guidelines)
|
||||
## 2. 编码规范 (Coding Style Guidelines)
|
||||
|
||||
### Rust 规范 (Backend)
|
||||
- 遵循 Rust 官方标准样式,提交前必须执行 `cargo fmt` 与 `cargo clippy`。
|
||||
@@ -66,7 +28,7 @@
|
||||
|
||||
---
|
||||
|
||||
## 4. 测试与验证 (Testing)
|
||||
## 3. 测试与验证 (Testing)
|
||||
|
||||
### 运行后端单元测试
|
||||
系统为各个下载、解析、词典分词、接口提取等模块设计了健全的测试。运行测试命令:
|
||||
@@ -89,7 +51,7 @@ cargo run --bin health_check
|
||||
|
||||
---
|
||||
|
||||
## 5. 数据库迁移 (Database Migrations)
|
||||
## 4. 数据库迁移 (Database Migrations)
|
||||
|
||||
添加新的数据库字段或表时,需在 `migrations/` 目录下创建新的迁移脚本:
|
||||
1. 文件命名格式:`YYYYMMDDHHMMSS_description.sql`
|
||||
|
||||
Reference in New Issue
Block a user