instincts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package instincts provides parsing and importing of ECC instinct files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToObservation

func ConvertToObservation(inst *Instinct) *models.ParsedObservation

ConvertToObservation maps an instinct to a parsed guidance observation suitable for storage via ObservationStore.StoreObservation.

func DefaultBaseDir

func DefaultBaseDir() (string, error)

DefaultBaseDir returns the default base directory for instinct files: ~/.claude/homunculus/instincts/

func InstinctImportanceScore

func InstinctImportanceScore(confidence float64) float64

InstinctImportanceScore returns the importance score derived from an instinct's confidence value. The returned score is in the [0, 1] range, consistent with the system-wide importance score convention.

func IsDuplicate

func IsDuplicate(ctx context.Context, vectorClient vector.Client, title string, threshold float64) (bool, error)

IsDuplicate checks if an observation with similar content already exists. It performs a vector similarity query filtered to observation vectors only, and returns true if a result with similarity >= threshold is found. Returns an error if vectorClient is nil, since without dedup the import cannot guarantee idempotency.

func ResolveDir

func ResolveDir(requested string) (string, error)

ResolveDir validates and resolves a requested path against the allowed base directory. If requested is empty, returns the base directory. Returns an error if the resolved path escapes the base directory.

Types

type ImportResult

type ImportResult struct {
	Total    int      `json:"total"`
	Imported int      `json:"imported"`
	Skipped  int      `json:"skipped"`
	Errors   []string `json:"errors,omitempty"`
}

ImportResult summarizes the outcome of an import operation.

func Import

func Import(ctx context.Context, dir string, vectorClient vector.Client, obsStore *gorm.ObservationStore) (*ImportResult, error)

Import reads all instinct files from dir, deduplicates, and creates observations.

type Instinct

type Instinct struct {
	ID         string  `yaml:"id"`
	Trigger    string  `yaml:"trigger"`
	Confidence float64 `yaml:"confidence"`
	Domain     string  `yaml:"domain"`
	Source     string  `yaml:"source"`
	Body       string  `yaml:"-"`
	FilePath   string  `yaml:"-"`
}

Instinct represents a parsed ECC instinct file.

func ParseDir

func ParseDir(dir string) ([]*Instinct, []error)

ParseDir parses all .md files in a directory (non-recursive).

func ParseFile

func ParseFile(path string) (*Instinct, error)

ParseFile parses a single instinct markdown file with YAML frontmatter.

Jump to

Keyboard shortcuts

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