instincts

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 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.

func ImportFromContent added in v0.4.0

func ImportFromContent(ctx context.Context, files []InstinctFile, vectorClient vector.Client, obsStore *gorm.ObservationStore) (*ImportResult, error)

ImportFromContent imports instincts from file content sent over the wire. This is the client-server counterpart to Import() which reads from disk.

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 ParseContent added in v0.4.0

func ParseContent(name, content string) (*Instinct, error)

ParseContent parses a single instinct from its raw markdown content.

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.

type InstinctFile added in v0.4.0

type InstinctFile struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

InstinctFile represents a single instinct file sent over the wire.

Jump to

Keyboard shortcuts

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