commands

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package commands implements CLI commands for llm-clarification.

Index

Constants

This section is empty.

Variables

View Source
var (
	GlobalJSONOutput bool
	GlobalMinOutput  bool
)

Global output flags accessible to all commands

View Source
var Version = "1.2.0"

Version is set at build time using ldflags

Functions

func Execute

func Execute() error

Execute runs the root command.

func FileOrDBExists added in v1.2.0

func FileOrDBExists(filePath string) bool

FileOrDBExists checks if the storage file exists. For YAML files, uses os.Stat. For SQLite files, uses os.Stat.

func GetDBPath added in v1.2.0

func GetDBPath(cmdFilePath string) string

GetDBPath returns the effective database path. Priority: --db flag > CLARIFY_DB_PATH env var > per-command --file flag

func GetStorage added in v1.2.0

func GetStorage(ctx context.Context, filePath string) (storage.Storage, error)

GetStorage creates a Storage instance for the given file path. It uses the factory pattern to detect storage type from file extension. The caller is responsible for calling Close() on the returned Storage.

func GetStorageOrError added in v1.2.0

func GetStorageOrError(ctx context.Context, filePath string) (storage.Storage, error)

GetStorageOrError creates a Storage instance, checking file existence first. For YAML files, it checks if the file exists. For SQLite files, it creates the database if it doesn't exist.

func LoadEntriesFromStorage added in v1.2.0

func LoadEntriesFromStorage(ctx context.Context, filePath string) ([]tracking.Entry, error)

LoadEntriesFromStorage loads all entries from storage. This is a convenience function for commands that need to load all entries.

func NewDeleteClarificationCmd added in v1.2.0

func NewDeleteClarificationCmd() *cobra.Command

NewDeleteClarificationCmd creates a new delete-clarification command.

func NewExportMemoryCmd added in v1.2.0

func NewExportMemoryCmd() *cobra.Command

NewExportMemoryCmd creates a new export-memory command.

func NewImportMemoryCmd added in v1.2.0

func NewImportMemoryCmd() *cobra.Command

NewImportMemoryCmd creates a new import-memory command.

func NewOptimizeMemoryCmd added in v1.2.0

func NewOptimizeMemoryCmd() *cobra.Command

NewOptimizeMemoryCmd creates a new optimize-memory command.

func NewReconcileMemoryCmd added in v1.2.0

func NewReconcileMemoryCmd() *cobra.Command

NewReconcileMemoryCmd creates a new reconcile-memory command.

func SetLLMClient

func SetLLMClient(client LLMClientInterface)

SetLLMClient sets the LLM client (for testing).

Types

type AddClarificationResult

type AddClarificationResult struct {
	Status           string   `json:"status"`
	ID               string   `json:"id"`
	Message          string   `json:"message"`
	PotentialMatches []string `json:"potential_matches,omitempty"`
}

AddClarificationResult represents the JSON output of the add-clarification command.

type Candidate

type Candidate struct {
	ID          string  `json:"id"`
	Question    string  `json:"question"`
	Occurrences int     `json:"occurrences"`
	Confidence  float64 `json:"confidence"`
	Reason      string  `json:"reason"`
}

Candidate represents a promotion candidate.

type CandidatesResult

type CandidatesResult struct {
	Status     string      `json:"status"`
	Candidates []Candidate `json:"candidates"`
	Total      int         `json:"total"`
}

CandidatesResult represents the JSON output of the identify-candidates command.

type Cluster

type Cluster struct {
	Label           string   `json:"label"`
	QuestionIndices []int    `json:"question_indices"`
	Questions       []string `json:"questions,omitempty"`
}

Cluster represents a group of similar questions.

type ClusterResult

type ClusterResult struct {
	Status       string    `json:"status"`
	Clusters     []Cluster `json:"clusters"`
	ClusterCount int       `json:"cluster_count"`
	Note         string    `json:"note,omitempty"`
}

ClusterResult represents the JSON output of the cluster-clarifications command.

type Conflict

type Conflict struct {
	EntryIDs   []string        `json:"entry_ids"`
	Reason     string          `json:"reason"`
	Severity   string          `json:"severity"`
	Suggestion string          `json:"suggestion"`
	Entries    []ConflictEntry `json:"entries,omitempty"`
}

Conflict represents a detected conflict between entries.

type ConflictEntry

type ConflictEntry struct {
	ID       string `json:"id"`
	Question string `json:"question"`
	Answer   string `json:"answer"`
}

ConflictEntry represents an entry involved in a conflict.

type ConflictsResult

type ConflictsResult struct {
	Status        string     `json:"status"`
	Conflicts     []Conflict `json:"conflicts"`
	ConflictCount int        `json:"conflict_count"`
	Note          string     `json:"note,omitempty"`
}

ConflictsResult represents the JSON output of the detect-conflicts command.

type ConsolidationResult

type ConsolidationResult struct {
	Status      string                    `json:"status"`
	Suggestions []ConsolidationSuggestion `json:"suggestions"`
	Total       int                       `json:"total"`
}

ConsolidationResult represents the JSON output of the suggest-consolidation command.

type ConsolidationSuggestion

type ConsolidationSuggestion struct {
	PrimaryID      string   `json:"primary_id"`
	MergeIDs       []string `json:"merge_ids"`
	Reason         string   `json:"reason"`
	SuggestedMerge string   `json:"suggested_merge,omitempty"`
}

ConsolidationSuggestion represents a suggested merge.

type DeleteClarificationResult added in v1.2.0

type DeleteClarificationResult struct {
	File      string `json:"file,omitempty"`
	F         string `json:"f,omitempty"`
	ID        string `json:"id,omitempty"`
	I         string `json:"i,omitempty"`
	Question  string `json:"question,omitempty"`
	Q         string `json:"q,omitempty"`
	Status    string `json:"status,omitempty"`
	S         string `json:"s,omitempty"`
	Deleted   bool   `json:"deleted,omitempty"`
	D         *bool  `json:"d,omitempty"`
	Cancelled bool   `json:"cancelled,omitempty"`
	C         *bool  `json:"c,omitempty"`
}

DeleteClarificationResult holds the deletion result

type ExportMemoryResult added in v1.2.0

type ExportMemoryResult struct {
	Source  string `json:"source,omitempty"`
	Src     string `json:"src,omitempty"`
	Output  string `json:"output,omitempty"`
	Out     string `json:"out,omitempty"`
	Entries int    `json:"entries,omitempty"`
	E       *int   `json:"e,omitempty"`
	Status  string `json:"status,omitempty"`
	S       string `json:"s,omitempty"`
}

ExportMemoryResult holds the export result

type ImportMemoryResult added in v1.2.0

type ImportMemoryResult struct {
	Source    string `json:"source,omitempty"`
	Src       string `json:"src,omitempty"`
	Target    string `json:"target,omitempty"`
	Tgt       string `json:"tgt,omitempty"`
	Mode      string `json:"mode,omitempty"`
	M         string `json:"m,omitempty"`
	Processed int    `json:"processed,omitempty"`
	Pr        *int   `json:"pr,omitempty"`
	Created   int    `json:"created,omitempty"`
	Cr        *int   `json:"cr,omitempty"`
	Updated   int    `json:"updated,omitempty"`
	Upd       *int   `json:"upd,omitempty"`
	Skipped   int    `json:"skipped,omitempty"`
	Sk        *int   `json:"sk,omitempty"`
	Errors    int    `json:"errors,omitempty"`
	Er        *int   `json:"er,omitempty"`
}

ImportMemoryResult holds the import result

type InitResult

type InitResult struct {
	Status  string `json:"status"`
	File    string `json:"file"`
	Message string `json:"message"`
}

InitResult represents the JSON output of the init-tracking command.

type LLMClientInterface

type LLMClientInterface interface {
	Complete(prompt string, timeout time.Duration) (string, error)
}

LLMClientInterface defines the interface for LLM clients.

type ListEntriesResult

type ListEntriesResult struct {
	Count   int              `json:"count"`
	Entries []tracking.Entry `json:"entries"`
}

ListEntriesResult represents the JSON output of the list-entries command.

type MatchResult

type MatchResult struct {
	Status     string  `json:"status"`
	MatchID    string  `json:"match_id,omitempty"`
	Confidence float64 `json:"confidence,omitempty"`
	Reason     string  `json:"reason,omitempty"`
	Question   string  `json:"question,omitempty"`
	Answer     string  `json:"answer,omitempty"`
}

MatchResult represents the JSON output of the match-clarification command.

type NormalizeResult

type NormalizeResult struct {
	Status             string `json:"status"`
	OriginalQuestion   string `json:"original_question"`
	NormalizedQuestion string `json:"normalized_question"`
	Changes            string `json:"changes,omitempty"`
}

NormalizeResult represents the JSON output of the normalize-clarification command.

type OptimizeMemoryResult added in v1.2.0

type OptimizeMemoryResult struct {
	File          string         `json:"file,omitempty"`
	F             string         `json:"f,omitempty"`
	VacuumBytes   int64          `json:"vacuum_bytes,omitempty"`
	VB            *int64         `json:"vb,omitempty"`
	PrunedEntries int            `json:"pruned_entries,omitempty"`
	PE            *int           `json:"pe,omitempty"`
	TotalEntries  int            `json:"total_entries,omitempty"`
	TE            *int           `json:"te,omitempty"`
	TotalVariants int            `json:"total_variants,omitempty"`
	TV            *int           `json:"tv,omitempty"`
	TotalTags     int            `json:"total_tags,omitempty"`
	TT            *int           `json:"tt,omitempty"`
	TotalSprints  int            `json:"total_sprints,omitempty"`
	TS            *int           `json:"ts,omitempty"`
	StorageSize   int64          `json:"storage_size,omitempty"`
	SS            *int64         `json:"ss,omitempty"`
	LastModified  string         `json:"last_modified,omitempty"`
	LM            string         `json:"lm,omitempty"`
	ByStatus      map[string]int `json:"by_status,omitempty"`
	BS            map[string]int `json:"bs,omitempty"`
}

OptimizeMemoryResult holds the optimization result

type PotentialMatch

type PotentialMatch struct {
	ID       string `json:"id"`
	Question string `json:"question"`
}

PotentialMatch represents a similar existing question.

type PromoteResult

type PromoteResult struct {
	Status  string `json:"status"`
	ID      string `json:"id"`
	Target  string `json:"target"`
	Message string `json:"message"`
}

PromoteResult represents the JSON output of the promote-clarification command.

type ReconcileMemoryResult added in v1.2.0

type ReconcileMemoryResult struct {
	File          string   `json:"file,omitempty"`
	F             string   `json:"f,omitempty"`
	ProjectRoot   string   `json:"project_root,omitempty"`
	PR            string   `json:"pr,omitempty"`
	DryRun        bool     `json:"dry_run,omitempty"`
	DR            *bool    `json:"dr,omitempty"`
	TotalScanned  int      `json:"total_scanned,omitempty"`
	TS            *int     `json:"ts,omitempty"`
	StaleFound    int      `json:"stale_found,omitempty"`
	SF            *int     `json:"sf,omitempty"`
	StaleEntries  []string `json:"stale_entries,omitempty"`
	SE            []string `json:"se,omitempty"`
	MarkedAsStale int      `json:"marked_as_stale,omitempty"`
	MS            *int     `json:"ms,omitempty"`
}

ReconcileMemoryResult holds the reconciliation result

type ValidateClarificationsResult

type ValidateClarificationsResult struct {
	Status      string       `json:"status"`
	Validations []Validation `json:"validations"`
	ValidCount  int          `json:"valid_count"`
	StaleCount  int          `json:"stale_count"`
	ReviewCount int          `json:"review_count"`
}

ValidateClarificationsResult represents the JSON output of the validate-clarifications command.

type Validation

type Validation struct {
	ID             string `json:"id"`
	Status         string `json:"status"`
	Reason         string `json:"reason,omitempty"`
	Recommendation string `json:"recommendation,omitempty"`
}

Validation represents the validation status of an entry.

Jump to

Keyboard shortcuts

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