Help us shape the future of Go! Take the 2026 Go Developer Survey

prompts

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PromptEntry

type PromptEntry struct {
	ID        string    `json:"id"`
	Text      string    `json:"text"`
	Label     string    `json:"label"`
	UsedCount int       `json:"used_count"`
	LastUsed  time.Time `json:"last_used"`
	CreatedAt time.Time `json:"created_at"`
}

PromptEntry represents a single stored prompt with usage metadata.

type PromptStore

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

PromptStore manages a persistent JSON-backed collection of prompt entries.

func NewPromptStore

func NewPromptStore(filePath string) *PromptStore

NewPromptStore returns a new PromptStore backed by the given file path.

func (*PromptStore) Delete

func (s *PromptStore) Delete(id string) error

Delete removes the entry with the given ID. It is not an error if the ID does not exist.

func (*PromptStore) List

func (s *PromptStore) List(limit int) ([]PromptEntry, error)

List returns entries sorted by LastUsed descending. If limit <= 0, all entries are returned.

func (*PromptStore) Load

func (s *PromptStore) Load() ([]PromptEntry, error)

Load reads and deserializes the prompt entries from disk. Returns an empty (non-nil) slice and no error when the file does not exist.

func (*PromptStore) RecordUsage

func (s *PromptStore) RecordUsage(text string) (PromptEntry, error)

RecordUsage upserts a prompt entry by text, incrementing UsedCount and updating LastUsed. After upsert, the list is trimmed to 500 entries by evicting the entries with the oldest LastUsed timestamps.

func (*PromptStore) Save

func (s *PromptStore) Save(entries []PromptEntry) error

Save atomically writes entries to disk using a temp file + os.Rename.

Jump to

Keyboard shortcuts

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