Documentation
¶
Index ¶
- Constants
- Variables
- func BuildNotePrompt(ctx context.Context) string
- func FormatTime(t time.Time) string
- func GetDefaultPromptTemplate(role string) string
- func GetPromptPath(role string, global bool) (string, error)
- func GetPromptTemplate(ctx context.Context, role string) string
- func GetSystemPrompt(ctx context.Context) string
- func HandleNote(ctx context.Context, content string) (result, warning string, err error)
- func HandleRecall(ctx context.Context, keywordsStr string, days, limit int) (result, warning string, err error)
- func JudgeHistory(messages []*Message)
- func ResolvePromptEditPath(name string) (string, error)
- func ResolvePromptRemovePath(name string) (string, error)
- func SaveMessages(ctx context.Context, msgs ...Message) error
- func SaveNote(ctx context.Context, content string) error
- func ToSQLNullString(tcs []ToolCall) (toolCalls sql.NullString)
- func ToolCallsID(tcs []ToolCall) string
- func Truncate(content string, maxLen int) string
- func UpdateContent(ctx context.Context, id int64, content string) (err error)
- func UpdateHistory(ctx context.Context, id int64) (err error)
- func UpdateToolCalls(ctx context.Context, id int64, tcs []ToolCall) (err error)
- type Message
- func CleanupReverse(messages []Message) (cleaned []Message)
- func ListHistory(ctx context.Context) ([]*Message, error)
- func LoadHistory(ctx context.Context) ([]Message, error)
- func LoadPrompts(ctx context.Context) ([]Message, error)
- func ShowMessage(ctx context.Context, id int64) (message *Message, err error)
- type Note
- type PromptInfo
- type Result
- type ToolCall
- type ToolCallFunction
Constants ¶
const MaxNoteContentLen = 40
MaxNoteContentLen 笔记内容最大长度(rune),供 tool handler 参考
Variables ¶
var GetCurrentSessionID = session.GetCurrentSessionID
Functions ¶
func BuildNotePrompt ¶ added in v0.7.6
BuildNotePrompt 从近期笔记构建记忆线索提示词
func GetDefaultPromptTemplate ¶
GetDefaultPromptTemplate 获取内嵌的默认提示词模板 role: dev, expert, review
func GetPromptPath ¶
GetPromptPath 获取提示词文件路径 global: true表示全局配置,false表示项目配置
func GetPromptTemplate ¶
GetPromptTemplate 获取当前生效的提示词模板 优先级:项目配置(.dscli/prompt/) > 全局配置 > 内嵌默认模板 GetPromptTemplate 获取当前生效的提示词模板。 优先级:项目配置(.dscli/prompt/) > 全局配置 > 内嵌默认模板。 当数据库中存在 role→prompt 映射时,使用映射后的 prompt 名称加载模板;
func HandleNote ¶ added in v0.7.7
func HandleRecall ¶ added in v0.7.7
func JudgeHistory ¶ added in v0.7.7
func JudgeHistory(messages []*Message)
JudgeHistory - Cleanup the history
func ResolvePromptEditPath ¶ added in v0.7.8
ResolvePromptEditPath 确定编辑提示词的目标路径 优先编辑项目级别(若已存在);若不在项目中或文件不存在则使用全局 ResolvePromptEditPath 确定编辑提示词的目标路径 优先编辑项目级别(若已存在);若不在项目中或文件不存在则使用全局
func ResolvePromptRemovePath ¶ added in v0.7.8
ResolvePromptRemovePath 确定删除提示词的目标路径 优先项目级别(若存在),否则全局
func SaveMessages ¶ added in v0.7.6
SaveMessages 保存消息(事务) SaveMessages 保存消息(事务),同时同步 FTS5 全文索引。
func SaveNote ¶ added in v0.7.6
SaveNote 保存一条对话笔记(限制 MaxNoteContentLen 字以内)
func ToSQLNullString ¶ added in v0.7.7
func ToSQLNullString(tcs []ToolCall) (toolCalls sql.NullString)
func UpdateContent ¶ added in v0.7.7
UpdateContent update message content
func UpdateHistory ¶ added in v0.7.7
UpdateHistory update message session_id to 0
Types ¶
type Message ¶ added in v0.7.6
type Message struct {
ID int64 `json:"-"`
SessionID int64 `json:"-"`
ModelID int64 `json:"-"`
Role string `json:"role"`
ReasoningContent string `json:"reasoning_content"`
Content string `json:"content"` // 始终输出,即使为空字符串
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // 仅当有工具调用时输出
ToolCallID string `json:"tool_call_id,omitempty"` // 仅当 role="tool" 时输出
CreatedAt time.Time `json:"-"`
OK bool `json:"-"`
// contains filtered or unexported fields
}
Message 扩展,支持工具调用(注意:Content 字段不再使用 omitempty)
func CleanupReverse ¶ added in v0.7.7
CleanupReverse - make the messages clean, remove the mistake message
func ListHistory ¶ added in v0.7.7
ListHistory 加载指定会话的所有历史消息,按时间升序返回
func LoadHistory ¶ added in v0.7.7
LoadHistory 加载指定会话的所有历史消息,按时间升序返回
func LoadPrompts ¶ added in v0.7.6
LoadPrompts loads the system prompt combined with skill and note prompts. Only dev role gets skills and notes; expert/review roles skip them. LoadPrompts loads the system prompt combined with skill and note prompts. Skills are injected according to role config; when no config exists, only dev role gets skills (hardcoded fallback).
func ShowMessage ¶ added in v0.7.7
type Note ¶ added in v0.7.6
Note 对话笔记,用于跨对话记忆
type PromptInfo ¶ added in v0.7.8
type PromptInfo struct {
Name string
Description string
Source string // "built-in", "project", "global"
}
PromptInfo 提示词基本信息
func ListPrompts ¶ added in v0.7.8
func ListPrompts() []PromptInfo
ListPrompts 列出所有可用提示词(去重,项目优先 > 全局 > 内嵌)
type Result ¶ added in v0.7.7
Result 搜索结果
func SearchMessages ¶ added in v0.7.7
SearchMessages 搜索消息,使用 FTS5 全文搜索(中文分词,按相关性排序)。 只搜索 role=user 和 role=assistant(无tool_calls) 的消息。 仅搜索当前 session(对应当前项目)的消息,避免跨项目回忆。 keywords: 搜索关键词(空格分隔,OR 逻辑,匹配任一即返回)。 days: 搜索最近N天,<=0 表示不限时间。 limit: 返回结果数量上限。
type ToolCall ¶ added in v0.7.6
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolCallFunction `json:"function"`
}
Source Files
¶
- doc.go
- history.go
- message.go
- note.go
- prompt.go
- recall.go