qmd

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package qmd provides a shell-backed client for the QMD CLI.

Index

Constants

View Source
const (
	// DefaultBinaryPath is the default executable name used to locate QMD.
	DefaultBinaryPath = "qmd"
	// InstallCommand is the recommended install command for the QMD CLI.
	InstallCommand = "npm install -g @tobilu/qmd"
)

Variables

View Source
var (
	// ErrQMDUnavailable indicates the QMD CLI could not be found on PATH.
	ErrQMDUnavailable = errors.New("qmd is not available")
)

Functions

This section is empty.

Types

type ClientOption

type ClientOption func(*QMDClient)

ClientOption mutates a QMDClient configuration.

func WithBinaryPath

func WithBinaryPath(path string) ClientOption

WithBinaryPath overrides the executable used for QMD invocations.

func WithIndexName

func WithIndexName(name string) ClientOption

WithIndexName routes QMD commands to a named SQLite index.

type CollectionInfo

type CollectionInfo struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Pattern     string `json:"pattern"`
	Documents   int    `json:"documents"`
	LastUpdated string `json:"lastUpdated"`
}

CollectionInfo summarizes one indexed QMD collection.

type EmbedResult

type EmbedResult struct {
	DocsProcessed  int `json:"docsProcessed"`
	ChunksEmbedded int `json:"chunksEmbedded"`
	Errors         int `json:"errors"`
	DurationMs     int `json:"durationMs"`
}

EmbedResult mirrors QMD's embedding summary.

type EmbedStatus added in v0.0.4

type EmbedStatus string

EmbedStatus summarizes the outcome of the optional embedding phase.

const (
	// EmbedStatusNotRequested means the caller disabled embeddings.
	EmbedStatusNotRequested EmbedStatus = "not_requested"
	// EmbedStatusCompleted means embeddings ran successfully.
	EmbedStatusCompleted EmbedStatus = "completed"
	// EmbedStatusSkippedUnavailable means embeddings were skipped because the
	// runtime lacks sqlite-vec support.
	EmbedStatusSkippedUnavailable EmbedStatus = "skipped_unavailable"
)

type IndexOperation

type IndexOperation string

IndexOperation selects whether Index creates a collection or updates one.

const (
	// IndexOperationAdd creates a collection and performs the initial sync.
	IndexOperationAdd IndexOperation = "add"
	// IndexOperationUpdate refreshes an existing collection.
	IndexOperationUpdate IndexOperation = "update"
)

type IndexOptions

type IndexOptions struct {
	Operation      IndexOperation
	VaultPath      string
	CollectionName string
	Context        string
	Embed          bool
	ForceEmbed     bool
}

IndexOptions configures a collection sync invocation.

type IndexResult

type IndexResult struct {
	CollectionName string       `json:"collectionName"`
	UpdateResult   UpdateResult `json:"updateResult"`
	EmbedResult    *EmbedResult `json:"embedResult,omitempty"`
	EmbedStatus    EmbedStatus  `json:"embedStatus"`
	EmbedWarning   string       `json:"embedWarning,omitempty"`
	Status         IndexStatus  `json:"status"`
}

IndexResult groups the collection sync summary, optional embedding summary, and the final index status snapshot.

type IndexStatus

type IndexStatus struct {
	TotalDocuments int              `json:"totalDocuments"`
	NeedsEmbedding int              `json:"needsEmbedding"`
	HasVectorIndex bool             `json:"hasVectorIndex"`
	Collections    []CollectionInfo `json:"collections"`
}

IndexStatus mirrors QMD's status view for collection health.

type QMDClient

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

QMDClient executes QMD shell commands with context-aware process management.

func NewClient

func NewClient(options ...ClientOption) *QMDClient

NewClient constructs a QMDClient with sensible defaults.

func (*QMDClient) Index

func (client *QMDClient) Index(ctx context.Context, options IndexOptions) (IndexResult, error)

Index creates or updates a QMD collection and returns the structured summary.

func (*QMDClient) Search

func (client *QMDClient) Search(ctx context.Context, options SearchOptions) ([]SearchResult, error)

Search executes a QMD search command and returns normalized results.

func (*QMDClient) Status

func (client *QMDClient) Status(ctx context.Context) (IndexStatus, error)

Status returns the current QMD index status summary.

type SearchMode

type SearchMode string

SearchMode selects the QMD retrieval mode for Search.

const (
	// SearchModeHybrid runs QMD's hybrid `query` command.
	SearchModeHybrid SearchMode = "hybrid"
	// SearchModeLexical runs QMD's lexical `search` command.
	SearchModeLexical SearchMode = "lexical"
	// SearchModeVector runs QMD's semantic `vsearch` command.
	SearchModeVector SearchMode = "vector"
)

type SearchOptions

type SearchOptions struct {
	Query      string
	Mode       SearchMode
	Limit      int
	All        bool
	MinScore   *float64
	Full       bool
	Collection string
}

SearchOptions configures a QMD search invocation.

type SearchResult

type SearchResult struct {
	DocID   string  `json:"docid,omitempty"`
	Path    string  `json:"path"`
	Title   string  `json:"title"`
	Snippet string  `json:"snippet"`
	Score   float64 `json:"score"`
}

SearchResult is the normalized Go representation of a QMD search hit.

type UpdateResult

type UpdateResult struct {
	Collections    int `json:"collections"`
	Indexed        int `json:"indexed"`
	Updated        int `json:"updated"`
	Unchanged      int `json:"unchanged"`
	Removed        int `json:"removed"`
	NeedsEmbedding int `json:"needsEmbedding"`
}

UpdateResult mirrors QMD's store update summary.

Jump to

Keyboard shortcuts

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