配置: - rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化 - Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则 - .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI - Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features - web: eslint flat config + prettier 配置 + package.json 脚本与依赖 - src/main.rs: loop→while 修复 clippy::never_loop 对抗性审查发现并修复: - eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error - 前端 lint 未接入 CI,现已补上 Lint 步骤 - Makefile 与 CI 的 clippy flags 不一致,已对齐
110 lines
3.8 KiB
Rust
110 lines
3.8 KiB
Rust
pub mod adapter;
|
||
pub mod adapters;
|
||
pub mod context;
|
||
pub mod handler;
|
||
pub mod handlers;
|
||
pub mod response;
|
||
|
||
use serde::{Deserialize, Serialize};
|
||
|
||
/// 统一命令枚举 - 与渠道无关
|
||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
#[serde(tag = "type", rename_all = "snake_case")]
|
||
pub enum Command {
|
||
/// 创建新话题(在同一个 Session 内)
|
||
CreateSession { title: Option<String> },
|
||
/// 保存当前话题内容到 Markdown 文件
|
||
SaveTopic {
|
||
filepath: Option<String>,
|
||
include_subagents: bool,
|
||
},
|
||
/// 保存会话内容到 Markdown 文件
|
||
SaveSession {
|
||
filepath: Option<String>,
|
||
include_all: bool,
|
||
include_subagents: bool,
|
||
},
|
||
/// 列出当前 Session 的所有话题
|
||
ListSessions { include_archived: bool },
|
||
/// 加载指定话题
|
||
LoadTopic { topic_id: String },
|
||
/// 切换到指定话题(清理当前历史并加载新话题)
|
||
SwitchTopic { topic_id: String },
|
||
/// 获取当前话题信息
|
||
GetCurrentSession,
|
||
/// 显示所有支持的命令
|
||
Help,
|
||
/// 列出所有可用通道
|
||
ListChannels,
|
||
/// 列出指定通道的所有会话
|
||
ListSessionsByChannel {
|
||
channel_name: String,
|
||
include_archived: bool,
|
||
},
|
||
/// 列出 Session 的所有 Topics
|
||
ListTopics { session_id: String },
|
||
/// 加载子智能体任务的消息历史
|
||
LoadTaskMessages { task_id: String },
|
||
/// 列出所有定时任务
|
||
ListSchedulerJobs,
|
||
/// 加载指定 channel + chat_id 的对话消息
|
||
LoadChatMessages { channel: String, chat_id: String },
|
||
/// 删除指定话题
|
||
DeleteTopic { topic_id: String },
|
||
/// 重命名指定话题
|
||
RenameTopic { topic_id: String, title: String },
|
||
/// 停止当前正在执行的 Agent
|
||
StopExecution,
|
||
/// 列出所有记忆
|
||
ListMemories,
|
||
/// 创建新记忆
|
||
CreateMemory {
|
||
namespace: String,
|
||
key: String,
|
||
content: String,
|
||
},
|
||
/// 更新已有记忆
|
||
UpdateMemory { id: String, content: String },
|
||
/// 删除记忆
|
||
DeleteMemory { id: String },
|
||
/// 列出所有技能
|
||
ListSkills,
|
||
/// 列出当前 Todo 列表
|
||
ListTodos {
|
||
/// 子代理的 task_id(进入子代理视图时传入)
|
||
#[serde(default)]
|
||
task_id: Option<String>,
|
||
},
|
||
}
|
||
|
||
impl Command {
|
||
/// 获取命令名称(用于日志和调试)
|
||
pub fn name(&self) -> &'static str {
|
||
match self {
|
||
Command::CreateSession { .. } => "create_session",
|
||
Command::SaveTopic { .. } => "save_topic",
|
||
Command::SaveSession { .. } => "save_session",
|
||
Command::ListSessions { .. } => "list_sessions",
|
||
Command::LoadTopic { .. } => "load_topic",
|
||
Command::SwitchTopic { .. } => "switch_topic",
|
||
Command::GetCurrentSession => "get_current_session",
|
||
Command::Help => "help",
|
||
Command::ListChannels => "list_channels",
|
||
Command::ListSessionsByChannel { .. } => "list_sessions_by_channel",
|
||
Command::ListTopics { .. } => "list_topics",
|
||
Command::LoadTaskMessages { .. } => "load_task_messages",
|
||
Command::ListSchedulerJobs => "list_scheduler_jobs",
|
||
Command::LoadChatMessages { .. } => "load_chat_messages",
|
||
Command::DeleteTopic { .. } => "delete_topic",
|
||
Command::RenameTopic { .. } => "rename_topic",
|
||
Command::StopExecution => "stop_execution",
|
||
Command::ListMemories => "list_memories",
|
||
Command::CreateMemory { .. } => "create_memory",
|
||
Command::UpdateMemory { .. } => "update_memory",
|
||
Command::DeleteMemory { .. } => "delete_memory",
|
||
Command::ListSkills => "list_skills",
|
||
Command::ListTodos { .. } => "list_todos",
|
||
}
|
||
}
|
||
}
|