Documentation
¶
Overview ¶
Package taste implements a learning system that observes user coding preferences and builds a style profile over time to improve agent output alignment.
Index ¶
- Constants
- func AllCategories() []string
- func AnalyzeCode(code string) map[string]string
- func DetectAbstractionLevel(code string) string
- func DetectCommentDensity(code string) float64
- func DetectErrorPattern(code string) string
- func DetectLanguage(code string) string
- func DetectNamingStyle(code string) string
- func DetectTestStyle(code string) string
- type Collector
- func (c *Collector) Cleanup(maxAge time.Duration)
- func (c *Collector) PendingCount() int
- func (c *Collector) RecentSignals(n int) []DiffSignal
- func (c *Collector) RecordEdit(id string, final string)
- func (c *Collector) RecordOutcome(id string, outcome Outcome)
- func (c *Collector) RecordProposal(id string, proposed string)
- type DiffSignal
- type Hooks
- func (h *Hooks) Collector() *Collector
- func (h *Hooks) OnCodeAccepted(sessionID, proposedCode string)
- func (h *Hooks) OnCodeEdited(sessionID, proposedCode, finalCode string)
- func (h *Hooks) OnCodeProposed(sessionID, proposedCode string) string
- func (h *Hooks) OnCodeRejected(sessionID, proposedCode string)
- func (h *Hooks) Profile() *Profile
- func (h *Hooks) PromptContext() string
- type Outcome
- type Profile
- type Proposal
- type Signal
- type Store
- func (s *Store) Delete(projectID string) error
- func (s *Store) Export(projectID string) ([]byte, error)
- func (s *Store) Import(data []byte) error
- func (s *Store) List() ([]string, error)
- func (s *Store) Load(projectID string) (*Profile, error)
- func (s *Store) Save(projectID string, profile *Profile) error
Constants ¶
const ( NamingCamelCase = "camelCase" NamingSnakeCase = "snake_case" NamingPascalCase = "PascalCase" NamingKebabCase = "kebab-case" )
Naming style constants.
const ( ErrorSentinel = "sentinel" ErrorWrapped = "wrapped" ErrorPanic = "panic" ErrorCustom = "custom_type" )
Error style constants.
const ( AbstractionInlined = "inlined" AbstractionExtracted = "extracted" )
Abstraction level constants.
const ( TestTableDriven = "table_driven" TestSubtests = "subtests" TestAssertLib = "assert_lib" TestPlain = "plain" )
Test style constants.
const ( CategoryNaming = "naming" CategoryComments = "comments" CategoryErrorHandling = "error_handling" CategoryAbstraction = "abstraction" CategoryTesting = "testing" CategoryFormatting = "formatting" )
Category constants for preference tracking.
const DefaultDecay = 0.95
DefaultDecay is the standard exponential decay rate for signals.
Variables ¶
This section is empty.
Functions ¶
func AllCategories ¶
func AllCategories() []string
AllCategories returns all supported preference categories.
func AnalyzeCode ¶
AnalyzeCode runs all detectors on a code sample and returns detected signals.
func DetectAbstractionLevel ¶
DetectAbstractionLevel estimates if code prefers inlining or extraction.
func DetectCommentDensity ¶
DetectCommentDensity returns the ratio of comment lines to total non-empty lines.
func DetectErrorPattern ¶
DetectErrorPattern analyzes Go/Python/JS code to categorize error handling style.
func DetectLanguage ¶
DetectLanguage attempts to identify the programming language from code content.
func DetectNamingStyle ¶
DetectNamingStyle analyzes code to determine the predominant naming convention.
func DetectTestStyle ¶
DetectTestStyle analyzes test code to determine testing patterns.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector observes agent output vs user final version and extracts style signals.
func NewCollector ¶
NewCollector creates a new taste collector bound to a profile.
func (*Collector) PendingCount ¶
PendingCount returns the number of proposals awaiting resolution.
func (*Collector) RecentSignals ¶
func (c *Collector) RecentSignals(n int) []DiffSignal
RecentSignals returns the diff signals from the last N interactions.
func (*Collector) RecordEdit ¶
RecordEdit stores what the user actually used and computes diff signals.
func (*Collector) RecordOutcome ¶
RecordOutcome marks the user's decision on a proposal.
func (*Collector) RecordProposal ¶
RecordProposal stores what the agent suggested.
type DiffSignal ¶
DiffSignal represents a detected style difference between proposed and final code.
func ComputeDiff ¶
func ComputeDiff(proposed, final string) []DiffSignal
ComputeDiff analyzes the nature of changes between proposed and final code.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks provides integration points for the engine/REPL loop to feed signals to the taste collector.
func (*Hooks) OnCodeAccepted ¶
OnCodeAccepted records that the user accepted the proposed code without edits.
func (*Hooks) OnCodeEdited ¶
OnCodeEdited records that the user modified the proposed code.
func (*Hooks) OnCodeProposed ¶
OnCodeProposed records a new code proposal from the agent.
func (*Hooks) OnCodeRejected ¶
OnCodeRejected records that the user rejected the proposed code entirely.
func (*Hooks) PromptContext ¶
PromptContext returns the current taste profile as a system prompt fragment.
type Profile ¶
type Profile struct {
Preferences map[string]Signal `json:"preferences"`
ProjectID string `json:"project_id,omitempty"`
Version int `json:"version"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
Profile holds a user's coding style preferences, keyed by category.
func NewProfile ¶
NewProfile creates a fresh empty profile.
func (*Profile) ToPromptContext ¶
ToPromptContext serializes the top preferences into a system prompt fragment.
type Proposal ¶
type Proposal struct {
ID string
Proposed string
Final string
Outcome Outcome
Signals []DiffSignal
RecordedAt time.Time
}
Proposal tracks what the agent proposed and how the user responded.
type Signal ¶
type Signal struct {
Value string `json:"value"`
Confidence float64 `json:"confidence"`
SampleCount int `json:"sample_count"`
LastUpdated time.Time `json:"last_updated"`
Decay float64 `json:"decay"`
}
Signal represents a single preference observation with confidence tracking.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages file-based persistence for taste profiles at ~/.hawk/taste/.
func NewStore ¶
NewStore creates a store rooted at the given base directory. If baseDir is empty, it defaults to ~/.hawk/taste/.