qmd

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckQMDAvailable

func CheckQMDAvailable(ctx context.Context, qmdPath string, timeout time.Duration) (bool, error)

CheckQMDAvailable 检查 QMD 是否可用

func CleanOldExports

func CleanOldExports(exportDir string, retentionDays int) error

CleanOldExports 清理过期的导出文件

func CreateCollection

func CreateCollection(ctx context.Context, qmdPath, name, path, pattern string, timeout time.Duration) error

CreateCollection 创建 QMD 集合

func EmbedCollection

func EmbedCollection(ctx context.Context, qmdPath, name string, timeout time.Duration) ([]byte, error)

EmbedCollection 为集合生成嵌入向量

func ExportAllSessions

func ExportAllSessions(sessionDir, exportDir string, retentionDays int) error

ExportAllSessions 导出所有会话

func ExportSessionToFile

func ExportSessionToFile(session *SessionFile, exportDir string, retentionDays int) error

ExportSessionToFile 导出单个会话到 Markdown

func FindSessionDir

func FindSessionDir(workspace string) (string, error)

FindSessionDir 查找会话目录

func GetQMDVersion

func GetQMDVersion(ctx context.Context, qmdPath string, timeout time.Duration) (string, error)

GetQMDVersion 获取 QMD 版本

func ListCollections

func ListCollections(ctx context.Context, qmdPath string, timeout time.Duration) ([]string, error)

ListCollections 列出所有集合

func RunQMDCommand

func RunQMDCommand(ctx context.Context, cmd *exec.Cmd, timeout time.Duration) ([]byte, error)

RunQMDCommand 执行 QMD 命令

func UpdateCollection

func UpdateCollection(ctx context.Context, qmdPath, name string, timeout time.Duration) ([]byte, error)

UpdateCollection 更新集合索引

Types

type CollectionStats

type CollectionStats struct {
	Name           string `json:"name"`
	DocumentCount  int    `json:"document_count"`
	EmbeddingCount int    `json:"embedding_count"`
	LastUpdate     string `json:"last_update"`
}

GetCollectionStats 获取集合统计信息

func GetCollectionStats

func GetCollectionStats(ctx context.Context, qmdPath, name string, timeout time.Duration) (*CollectionStats, error)

type Message

type Message struct {
	Role    string `json:"role"` // "user" | "assistant" | "system"
	Content string `json:"content"`
}

Message 消息格式

type QMDCollection

type QMDCollection struct {
	Name          string    `json:"name"`
	Path          string    `json:"path"`
	Pattern       string    `json:"pattern"`
	CreatedAt     time.Time `json:"created_at"`
	LastUpdate    time.Time `json:"last_updated"`
	DocumentCount int       `json:"document_count"`
}

QMDCollection QMD 集合配置

type QMDConfig

type QMDConfig struct {
	Command        string
	Enabled        bool
	IncludeDefault bool
	Paths          []QMDPathConfig
	Sessions       QMDSessionsConfig
	Update         QMDUpdateConfig
	Limits         QMDLimitsConfig
}

QMDConfig QMD 配置(从 config.MemoryConfig.QMD 映射)

func DefaultQMDConfig

func DefaultQMDConfig() QMDConfig

DefaultQMDConfig 返回默认 QMD 配置

type QMDLimitsConfig

type QMDLimitsConfig struct {
	MaxResults      int
	MaxSnippetChars int
	TimeoutMs       int
}

QMDLimitsConfig QMD 搜索限制配置

type QMDManager

type QMDManager struct {
	// contains filtered or unexported fields
}

QMDManager 管理 QMD 进程和集合

func NewQMDManager

func NewQMDManager(config QMDConfig, workspace, agentID string) *QMDManager

NewQMDManager 创建 QMD 管理器

func (*QMDManager) Close

func (m *QMDManager) Close() error

Close 清理资源

func (*QMDManager) Embed

func (m *QMDManager) Embed(ctx context.Context) error

Embed 生成嵌入向量

func (*QMDManager) GetStatus

func (m *QMDManager) GetStatus() *QMDStatus

GetStatus 获取状态

func (*QMDManager) Initialize

func (m *QMDManager) Initialize(ctx context.Context) error

Initialize 初始化 QMD(创建集合)

func (*QMDManager) Query

func (m *QMDManager) Query(ctx context.Context, query string) ([]QMDQueryResult, error)

Query 执行语义搜索

func (*QMDManager) Update

func (m *QMDManager) Update(ctx context.Context) error

Update 更新索引

type QMDPathConfig

type QMDPathConfig struct {
	Name    string
	Path    string
	Pattern string
}

QMDPathConfig QMD 路径配置

type QMDQueryResult

type QMDQueryResult struct {
	Path       string  `json:"path"`
	Line       int     `json:"line"`
	Snippet    string  `json:"snippet"`
	Score      float64 `json:"score"`
	Collection string  `json:"collection"`
}

QMDQueryResult QMD 查询结果

func QueryQMD

func QueryQMD(ctx context.Context, qmdPath, collection, query string, limit int, timeout time.Duration) ([]QMDQueryResult, error)

QueryQMD 执行 qmd query 命令

type QMDSessionsConfig

type QMDSessionsConfig struct {
	Enabled       bool
	ExportDir     string
	RetentionDays int
}

QMDSessionsConfig QMD 会话配置

type QMDStatus

type QMDStatus struct {
	Available       bool      `json:"available"`
	Version         string    `json:"version,omitempty"`
	Collections     []string  `json:"collections,omitempty"`
	LastUpdated     time.Time `json:"last_updated,omitempty"`
	LastEmbed       time.Time `json:"last_embed,omitempty"`
	IndexedFiles    int       `json:"indexed_files,omitempty"`
	TotalDocuments  int       `json:"total_documents,omitempty"`
	TotalEmbeddings int       `json:"total_embeddings,omitempty"`
	Error           string    `json:"error,omitempty"`
	FallbackEnabled bool      `json:"fallback_enabled"`
}

QMDStatus QMD 状态信息

type QMDUpdateConfig

type QMDUpdateConfig struct {
	Interval       time.Duration
	OnBoot         bool
	EmbedInterval  time.Duration
	CommandTimeout time.Duration
	UpdateTimeout  time.Duration
}

QMDUpdateConfig QMD 更新配置

type SessionFile

type SessionFile struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Messages  []Message `json:"messages"`
}

SessionFile 会话文件格式

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL