designmd

package
v1.31.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

internal/designmd/parse.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrandMeta

type BrandMeta struct {
	Vibe    string   `json:"vibe"`
	Colors  []string `json:"colors"`
	BestFor string   `json:"best_for"`
}

func ExtractMeta

func ExtractMeta(content string) BrandMeta

type IndexResult

type IndexResult struct {
	Brands  int
	Indexed int
	Skipped int
}

IndexResult summarizes an indexing run.

func Index

func Index(ctx context.Context, dir string, client *embed.Client, store *Store) (*IndexResult, error)

Index reads all */DESIGN.md files under dir, embeds sections via e5-large, and upserts to the design_embeddings table (1024-dim). Writes index.json with per-brand metadata.

type Record

type Record struct {
	Brand     string
	Section   string
	FilePath  string
	StartLine int
	BodyHash  uint64
	Embedding []float32
}

Record holds one design section embedding.

type SearchResult

type SearchResult struct {
	Brand    string
	Section  string
	FilePath string
	Distance float32
}

SearchResult is a single search hit.

type Section

type Section struct {
	Title     string
	Body      string
	StartLine int
}

func SplitSections

func SplitSections(content string) []Section

type Store

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

Store manages design embeddings in PostgreSQL with pgvector (1024-dim).

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

func (*Store) EnsureSchema

func (s *Store) EnsureSchema(ctx context.Context) error

EnsureSchema creates the pgvector extension and design_embeddings table if needed. After creating the table it attempts to transfer ownership to CURRENT_USER (best-effort: warns instead of failing if the role is not the table owner — e.g. after a superuser pg_restore left design_embeddings owned by the restoring role).

func (*Store) GetHashes

func (s *Store) GetHashes(ctx context.Context) (map[string]uint64, error)

GetHashes returns brand:section → body_hash for change detection.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query []float32, topK int) ([]SearchResult, error)

Search finds top-K most similar design sections.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, records []Record) error

Upsert stores design section embeddings.

Jump to

Keyboard shortcuts

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