![]() |
VOOZH | about |
dotnet add package GoesSoftware.SuperSDK.QuaffAgent --version 7.23.7
NuGet\Install-Package GoesSoftware.SuperSDK.QuaffAgent -Version 7.23.7
<PackageReference Include="GoesSoftware.SuperSDK.QuaffAgent" Version="7.23.7" />
<PackageVersion Include="GoesSoftware.SuperSDK.QuaffAgent" Version="7.23.7" />Directory.Packages.props
<PackageReference Include="GoesSoftware.SuperSDK.QuaffAgent" />Project file
paket add GoesSoftware.SuperSDK.QuaffAgent --version 7.23.7
#r "nuget: GoesSoftware.SuperSDK.QuaffAgent, 7.23.7"
#:package GoesSoftware.SuperSDK.QuaffAgent@7.23.7
#addin nuget:?package=GoesSoftware.SuperSDK.QuaffAgent&version=7.23.7Install as a Cake Addin
#tool nuget:?package=GoesSoftware.SuperSDK.QuaffAgent&version=7.23.7Install as a Cake Tool
可嵌入到 SuperSDK 应用中的编码 Agent,提供 AI 辅助编程、记忆管理、系统提示词配置和内嵌 Avalonia UI 等能力。
所有通知与数据交换均通过 SuperSDK.Core 的 MessageBus 以消息形式发布,不暴露任何 C# event。
CodingAgent (IQuaffAgentHandle)
├── AgentConfig — 运行参数配置(LLM、工作区、工具开关等)
├── MemManager — 记忆管理(mem.db / global_mem.db)
├── PromptRepo — 系统提示词块 CRUD(prompt_config 表)
└── UI 层(可选嵌入)
└── QuaffWindow
├── 对话 Tab — 发送消息、流式输出
├── 工具 Tab — 工具调用历史
├── 记忆 Tab — 查看/编辑记忆条目
├── 配置 Tab — Agent 配置项
└── 提示词 Tab — 系统提示词块可视化编辑
View 层与 Agent 完全解耦,只能通过 GzMessageBus 请求和接收数据,不持有任何对 Agent 或 DB 的直接引用。
using GoesSoftware.SuperSDK.QuaffAgent.Agent;
using GoesSoftware.SuperSDK.QuaffAgent.Messages;
using GzMessageBus = SuperSDK.Core.Messaging.MessageBus;
// 1. 创建 Agent
var agent = new CodingAgent(new AgentConfig
{
Name = "代码助手",
SessionName = "my-session",
WorkspaceRoot = @"D:\MyProject",
LlmEndpoint = "https://api.openai.com/v1",
LlmApiKey = "sk-...",
LlmModel = "gpt-4o",
});
// 2. 注册 ask_user 处理器(必须)
GzMessageBus.RegisterReqHandler<GzQuaffAskUserRequest, string>(this, async req =>
{
return await MyDialog.AskAsync(req.Question, req.Options);
});
// 3. 订阅输出消息
GzMessageBus.Subscribe<GzQuaffLlmTokenMsg>(this, msg => Console.Write(msg.Text));
GzMessageBus.Subscribe<GzQuaffStatusMsg>(this, msg => Console.WriteLine($"[{msg.Text}]"));
// 4. 发送任务
await agent.RunAsync("帮我审查 Program.cs 中的错误处理逻辑");
| 属性 | 类型 | 说明 |
|---|---|---|
Name |
string |
显示名称(可选,回落到 SessionName) |
SessionName |
string |
会话标识,影响记忆存储路径和消息 SessionName 字段 |
WorkspaceRoot |
string |
工作区根目录(必填) |
LlmEndpoint |
string |
LLM API 地址 |
LlmApiKey |
string |
API Key |
LlmModel |
string |
模型名称 |
MaxContextTokens |
int |
最大上下文长度(token) |
EnableTools |
bool |
是否启用工具调用 |
EnableRag |
bool |
是否启用 RAG 记忆注入 |
| 消息类型 | 触发时机 |
|---|---|
GzQuaffLlmTokenMsg |
LLM 流式输出每个增量 token |
GzQuaffStatusMsg |
Agent 内部状态/进度文字 |
GzQuaffErrorMsg |
发生错误时 |
GzQuaffToolCallStartMsg |
工具调用开始 |
GzQuaffToolCallEndMsg |
工具调用结束(含返回结果) |
GzQuaffToolDeniedMsg |
工具调用被用户拒绝 |
GzQuaffRagInjectedMsg |
RAG 上下文注入到用户消息时 |
GzQuaffTokenUsageMsg |
本轮对话的 token 用量统计 |
GzQuaffContextTrimmedMsg |
对话历史被裁剪时 |
GzQuaffSessionResetMsg |
调用 ResetSession() 后,会话被清空时 |
| 消息类型 | 方向 | 说明 |
|---|---|---|
GzQuaffGetSystemPromptRequest |
View → Agent | 请求获取当前系统提示词文本 |
GzQuaffSystemPromptUpdatedMsg |
Agent → View | 推送当前系统提示词文本(响应请求或保存后) |
GzQuaffSaveSystemPromptRequest |
View → Agent | 保存新的系统提示词文本 |
所有消息均继承 GzQuaffMessage,包含 SessionName(会话标识)和 Timestamp(时间戳)。
每个 Agent 对应一条系统提示词,定义该 Agent 的角色与行为。存储在工作区 mem.db 的 system_prompt 表中(单行)。
[system_prompt 表中的提示词文本] ← 可通过 UI 或代码配置
当前工作区:{workspace} ← 固定,不可配置
[全局记忆]
[项目记忆]
[Docs/ 目录文档]
打开 QuaffWindow → 切换到"提示词"选项卡:一个多行文本编辑器,输入后点击"保存"即可。
// 通过 IQuaffAgentHandle 接口
string current = agent.GetSystemPrompt();
agent.SaveSystemPrompt("你是一个专注于 C# 代码审查的 Agent,每次回答必须指出潜在的安全隐患。");
Agent 使用 SQLite 双库记忆:
| 数据库 | 路径 | 作用 |
|---|---|---|
| 项目记忆 | {workspace}/.quaff/mem.db |
项目专属观察记录、对话历史、提示词配置 |
| 全局记忆 | ~/.quaff/global_mem.db |
跨项目的通用经验 |
数据库由 MemDb.OpenMemDb(workspace) 自动创建并初始化 Schema,包含:
observations + observations_fts(FTS5 全文检索)conversations + conv_sessionsprompt_config(提示词块)ask_user 工具通过 GzMessageBus 发出请求,不使用 Console 或回调。
宿主必须在启动时注册一个处理器,否则 Agent 调用 ask_user 时会收到失败响应。
GzMessageBus.RegisterReqHandler<GzQuaffAskUserRequest, string>(this, async req =>
{
// req.Question — 需要问用户的问题文字
// req.Options — 可选项列表(可能为 null)
string answer = await MyDialog.AskAsync(req.Question, req.Options);
return answer;
});
RegisterReqHandler全局只能注册一个处理器;重复注册会覆盖上一个。
using GzMessageBus = SuperSDK.Core.Messaging.MessageBus;
using GoesSoftware.SuperSDK.QuaffAgent.Messages;
GzMessageBus.Subscribe<GzQuaffLlmTokenMsg>(this, msg => myOutputBox.Append(msg.Text));
GzMessageBus.Subscribe<GzQuaffStatusMsg>(this, msg => myStatusBar.Text = msg.Text);
GzMessageBus.Subscribe<GzQuaffErrorMsg>(this, msg => myLogger.Error(msg.Text));
GzMessageBus.Subscribe<GzQuaffToolCallStartMsg>(this, msg => myToolPanel.ShowRunning(msg.ToolName));
GzMessageBus.Subscribe<GzQuaffToolCallEndMsg>(this, msg => myToolPanel.ShowDone(msg.ToolName, msg.Result));
在 ViewModel 析构或
Dispose时,必须调用GzMessageBus.UnsubscribeAll(this)取消所有订阅。
SuperSDK.QuaffAgent 包含预制 Avalonia 窗口,可直接嵌入到任意 Avalonia 应用:
using GoesSoftware.SuperSDK.QuaffAgent.UI.Windows;
// 创建并绑定 Agent
var window = new QuaffWindow(agent); // agent 实现 IQuaffAgentHandle
window.Show();
窗口包含 5 个选项卡:
| 选项卡 | 功能 |
|---|---|
| 对话 | 发送消息、流式显示 LLM 输出 |
| 工具 | 工具调用历史记录 |
| 记忆 | 查看、搜索、删除记忆条目 |
| 配置 | 修改 AgentConfig(实时生效) |
| 提示词 | 可视化管理系统提示词块 |
GoesSoftware.SuperSDK.QuaffAgent 已注册到 gocli supersdk -upload 的发布列表,类型为 ObfuscateWithPublish。
# 随其他包一起发布
gocli supersdk -upload 7.22.0 "feat: 新增系统提示词配置系统"
# 单独发布
gocli supersdk -upload 7.22.0 -pkg quaffagent "feat: 提示词 DB 配置"
public event,所有输出通道均为消息总线订阅。SessionName 字段可用于在同一进程中区分多个 Agent 实例的消息。QuaffWindow)不持有对 DB 或 Agent 内部类的任何直接引用,所有操作均通过 GzMessageBus。| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on GoesSoftware.SuperSDK.QuaffAgent:
| Package | Downloads |
|---|---|
|
GoesSoftware.SuperSDK.Editor
SuperSDK 编辑器组件库 - 提供文件浏览器、代码编辑器、版本控制面板,原生集成 MessageBus |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.23.7 | 117 | 5/22/2026 |
| 7.23.6 | 112 | 5/22/2026 |
| 7.23.5 | 113 | 5/13/2026 |
| 7.23.4 | 105 | 5/13/2026 |
| 7.23.3 | 109 | 5/13/2026 |
| 7.23.2 | 118 | 5/13/2026 |
| 7.23.1 | 124 | 5/12/2026 |
| 7.23.0 | 116 | 5/12/2026 |
| 7.21.0 | 112 | 5/12/2026 |
| 7.20.0 | 113 | 5/12/2026 |
| 7.19.1 | 122 | 5/11/2026 |
| 7.19.0 | 112 | 5/11/2026 |
| 7.18.0 | 117 | 4/30/2026 |
| 7.17.0 | 116 | 4/29/2026 |
docs(gotest-agent): add Profile file naming rule to engineer prompt