domain

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package domain implements the core business logic of the application.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidDirPath indicates that the provided directory path is invalid.
	ErrInvalidDirPath = errors.New("invalid directory path")
	// ErrFileOperation indicates a failure during file operations.
	ErrFileOperation = errors.New("file operation failed")
	// ErrTokenization indicates a failure during tokenization.
	ErrTextProcessing = errors.New("text processing failed")
	// ErrEmptyDir indicates that no eligible files were found in the specified
	// directory.
	ErrEmptyDir = errors.New("no eligible files found in directory")
	// ErrTooManyErrors indicates that too many errors occurred during directory
	// processing, leading to an abort.
	ErrTooManyErrors = errors.New("too many errors during directory processing")
	// ErrNoTokensFound indicates that no tokens were found after processing the
	// files in the specified directory.
	ErrNoTokensFound = errors.New("no tokens found in directory")
)

Functions

func ProcessDirectory

func ProcessDirectory(dirPath string) error

ProcessDirectory tokenizes all eligible files in the specified directory and stores the tokens in the database. It returns an error if a set number of errors occur during processing.

func Progress added in v0.2.0

func Progress() float64

Progress returns the current progress of directory processing as a float between 0 and 1.

func Prompt

func Prompt() (string, error)

Prompt generates a prompt of the maximum specified character length from tokens of the specified directory. This is the main entry point of the domain package.

The function pools prompts in the background for efficiency.

If the TYPOMAT_PROMPT environment variable is set, its value is used directly as the prompt, bypassing text generation.

func Setup added in v0.2.0

func Setup(dirPath string, maxLen int) error

Setup initializes the domain package with the specified directory path and maximum prompt length.

This function should be called once at application startup. Subsequent calls have no effect.

Types

type FileStatus

type FileStatus int

FileStatus represents the status of a file with respect to the database.

const (
	// FileStatusUnchanged indicates the file is unchanged since last
	// tokenization.
	FileStatusUnchanged FileStatus = iota
	// FileStatusChanged indicates the file has changed since last tokenization.
	FileStatusChanged
	// FileStatusNew indicates the file is new and not present in the database.
	FileStatusNew
	// FileStatusIneligible indicates the file is ineligible for tokenization.
	FileStatusIneligible
)

Jump to

Keyboard shortcuts

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