feat: add memory template customization feature#592
Open
toarujs wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Memory 模板功能集成 - 变更文档
概述
在 MonkeyCode 平台中添加"Memory 模板"自定义功能,允许用户在设置中自定义
.monkeycode/MEMORY.md文件的初始化模板。后端修改
1. 数据库 Schema
文件:
backend/ent/schema/user.go修改内容:
说明: 在 User 表中添加
memory_template字段,类型为字符串,可选,可空。2. 领域模型
文件:
backend/domain/user.go修改 User 结构体
修改 From 方法
修改 UpdateUserReq 结构体
修改 UserRepo 接口
3. 仓库层
文件:
backend/biz/user/repo/user.go新增方法:
4. 业务逻辑层
文件:
backend/biz/user/usecase/user.go修改 Update 方法:
5. API Handler(新增)
文件:
backend/biz/setting/handler/v1/memory_template.go6. 注册
文件:
backend/biz/setting/register.go修改内容:
7. 自动生成的 Ent 代码
以下文件由 Ent 代码生成工具自动生成,无需手动修改:
backend/db/user.go- User 实体添加 MemoryTemplate 字段backend/db/user/user.go- 添加 FieldMemoryTemplate 常量backend/db/user/where.go- 添加 MemoryTemplate 查询条件backend/db/user_create.go- 添加创建时设置 MemoryTemplatebackend/db/user_update.go- 添加更新 MemoryTemplate 方法backend/db/mutation.go- 添加 Mutation 方法backend/db/runtime/runtime.go- 运行时配置backend/db/migrate/schema.go- 数据库迁移配置前端修改
1. 新增组件
文件:
frontend/src/components/console/settings/memory-template.tsx2. 设置对话框
文件:
frontend/src/components/console/settings/settings-dialog.tsx导入部分
导航配置
内容路由
修复滚动
API 接口文档
获取 Memory 模板
接口:
GET /api/v1/users/settings/memory-template响应:
{ "code": 200, "data": "模板内容...", "message": "ok" }说明: 如果用户未设置模板,返回空字符串。
保存 Memory 模板
接口:
PUT /api/v1/users/settings/memory-template请求体:
{ "memory_template": "模板内容..." }响应:
{ "code": 200, "data": null, "message": "ok" }限制: 模板大小最大 500KB。
删除 Memory 模板
接口:
DELETE /api/v1/users/settings/memory-template响应:
{ "code": 200, "data": null, "message": "ok" }说明: 删除后恢复为系统默认模板。
模板变量
{{date}}{{datetime}}{{project_name}}{{user_name}}{{workspace_path}}数据流
测试步骤
注意事项
memory_template字段