Documentation
¶
Overview ¶
internal/compile/backend.go
internal/compile/llm.go
internal/compile/tiered.go
Index ¶
- func BuildPrompt(promptTemplate string, cfg config.Config, globalSkillsDir string) string
- func CountEventsSinceMarker(paths config.Paths) (int, time.Time, error)
- func GatherAllLogs(paths config.Paths, maxLines int) ([]ingest.Event, error)
- func GatherUnprocessedLogs(paths config.Paths, maxLines int) ([]ingest.Event, error)
- func ReadMarker(path string) (time.Time, error)
- func RunCompile(paths config.Paths, cfg config.Config, promptTemplate string) error
- func WriteMarker(path string, t time.Time) error
- type CompilerBackend
- type DeterministicBackend
- type LLMBackend
- type LLMBackendConfig
- type Manifest
- type ROI
- type SessionSummary
- type SkillResult
- type TieredCompiler
- type TraceAnalysisResult
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt takes a prompt template string and replaces config variables.
func CountEventsSinceMarker ¶ added in v0.1.7
CountEventsSinceMarker counts events in log files newer than the compile marker without loading them into memory. Returns the count and marker time.
func GatherAllLogs ¶ added in v0.1.9
GatherAllLogs reads all JSONL events from log files regardless of the compile marker. Returns events sorted by timestamp, capped at maxLines.
func GatherUnprocessedLogs ¶
GatherUnprocessedLogs reads all JSONL events from log files newer than the last compile marker. Returns events sorted by timestamp, capped at maxLines.
func ReadMarker ¶
ReadMarker reads the timestamp from the compile marker file. Returns zero time if file doesn't exist.
func RunCompile ¶
RunCompile executes the full compilation sequence.
Types ¶
type CompilerBackend ¶ added in v0.1.8
type CompilerBackend interface {
// Name returns the backend's identifier (e.g. "aj-deterministic", "aj-llm").
Name() string
// Compile takes parameterized patterns and produces skills.
Compile(ctx context.Context, patterns []trace.Pattern) ([]SkillResult, error)
}
CompilerBackend is the interface for pluggable compilation strategies.
type DeterministicBackend ¶ added in v0.1.8
type DeterministicBackend struct {
// contains filtered or unexported fields
}
DeterministicBackend compiles parameterized patterns into deterministic shell scripts (bash + PowerShell) rather than relying on an LLM.
func NewDeterministicBackend ¶ added in v0.1.8
func NewDeterministicBackend(paths config.Paths, platform string) *DeterministicBackend
NewDeterministicBackend creates a new deterministic codegen backend.
func (*DeterministicBackend) Compile ¶ added in v0.1.8
func (b *DeterministicBackend) Compile(ctx context.Context, patterns []trace.Pattern) ([]SkillResult, error)
Compile iterates patterns and produces a skill for each.
func (*DeterministicBackend) Name ¶ added in v0.1.8
func (b *DeterministicBackend) Name() string
Name returns the backend identifier.
type LLMBackend ¶ added in v0.1.8
type LLMBackend struct {
// contains filtered or unexported fields
}
LLMBackend delegates compilation to Claude via the existing RunCompile flow.
func NewLLMBackend ¶ added in v0.1.8
func NewLLMBackend(cfg LLMBackendConfig) *LLMBackend
NewLLMBackend creates a new LLM compiler backend.
func (*LLMBackend) Compile ¶ added in v0.1.8
func (b *LLMBackend) Compile(ctx context.Context, patterns []trace.Pattern) ([]SkillResult, error)
Compile invokes the existing Claude-based compilation for the given patterns. In the LLM backend, patterns are informational — the LLM does its own pattern detection from logs. This method runs the full RunCompile flow.
func (*LLMBackend) Name ¶ added in v0.1.8
func (b *LLMBackend) Name() string
Name returns the backend identifier.
type LLMBackendConfig ¶ added in v0.1.8
LLMBackendConfig holds configuration for the LLM-based compiler backend.
type Manifest ¶
type Manifest struct {
LogsDir string `json:"logs_dir"`
SkillsDir string `json:"skills_dir"`
TotalSessions int `json:"total_sessions"`
TotalEvents int `json:"total_events"`
DateRange [2]string `json:"date_range"`
Sessions []SessionSummary `json:"sessions"`
}
Manifest is the concise overview given to the compiler.
type ROI ¶ added in v0.1.8
type ROI struct {
StochasticTokensPerRun int `json:"stochastic_tokens_per_run"`
DeterministicOverhead int `json:"deterministic_overhead"`
TokensSavedPerRun int `json:"tokens_saved_per_run"`
}
ROI holds the return-on-investment estimate for a deterministic skill.
type SessionSummary ¶
type SessionSummary struct {
SessionID string `json:"session_id"`
Date string `json:"date"`
FilePath string `json:"file_path"`
EventCount int `json:"event_count"`
ToolNames []string `json:"tool_names"`
WorkingDirectory string `json:"working_directory"`
}
SessionSummary is a lightweight summary of a single session log file.
type SkillResult ¶ added in v0.1.8
type SkillResult struct {
Name string // skill directory name
Path string // full path to the skill directory
CreatedBy string // backend name that produced this skill
}
SkillResult represents a skill produced by a compiler backend.
type TieredCompiler ¶ added in v0.1.8
type TieredCompiler struct {
// contains filtered or unexported fields
}
TieredCompiler routes patterns to deterministic or LLM backends based on confidence scoring.
func NewTieredCompiler ¶ added in v0.1.8
func NewTieredCompiler(deterministic, llm CompilerBackend, threshold float64) *TieredCompiler
NewTieredCompiler creates a compiler that routes patterns by confidence score.
func (*TieredCompiler) Compile ¶ added in v0.1.8
func (tc *TieredCompiler) Compile(ctx context.Context, patterns []trace.Pattern) ([]SkillResult, error)
Compile routes patterns to the appropriate backend and merges results.
type TraceAnalysisResult ¶ added in v0.1.8
type TraceAnalysisResult struct {
PatternsFound int
DeterministicCount int
LLMCount int
SkillsCreated []SkillResult
}
TraceAnalysisResult holds the outcome of the trace pre-pass.
func RunTraceAnalysis ¶ added in v0.1.8
RunTraceAnalysis performs the deterministic trace analysis pre-pass. It gathers unprocessed events, builds a trace graph, finds hot paths, parameterizes them, and compiles confident patterns deterministically.
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger evaluates whether the compilation should fire.
func NewTrigger ¶
NewTrigger creates a Trigger with the given config.
func (*Trigger) MarkFired ¶
func (tr *Trigger) MarkFired()
MarkFired records that a compile was just triggered.
func (*Trigger) SetRunning ¶
SetRunning marks the compilation as currently running (prevents concurrent runs).